twd-m4sc0 1.4.0__tar.gz → 1.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twd_m4sc0
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A tool to temporarily save and go to a working directory
5
5
  Home-page: https://github.com/m4sc0/twd
6
6
  Author: m4sc0
@@ -35,7 +35,7 @@ pip install twd-m4sc0
35
35
  2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
36
36
 
37
37
  ```bash
38
- eval $(twd --shell)
38
+ eval $(python3 -m twd --shell)
39
39
  ```
40
40
 
41
41
  3. Exit and reopen the terminal or reload using:
@@ -110,6 +110,19 @@ user:~/.config $ twd -s
110
110
  Saved TWD to /home/user/.config
111
111
  ```
112
112
 
113
+ #### Force
114
+
115
+ Forces an action
116
+
117
+ > Currently only implemented on the `-u` flag
118
+
119
+ - Example
120
+
121
+ ```bash
122
+ user:~/.config $ twd -u --force
123
+ TWD File deleted and TWD unset
124
+ ```
125
+
113
126
  # Contribution
114
127
 
115
128
  To set up a dev environment:
@@ -22,7 +22,7 @@ pip install twd-m4sc0
22
22
  2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
23
23
 
24
24
  ```bash
25
- eval $(twd --shell)
25
+ eval $(python3 -m twd --shell)
26
26
  ```
27
27
 
28
28
  3. Exit and reopen the terminal or reload using:
@@ -97,6 +97,19 @@ user:~/.config $ twd -s
97
97
  Saved TWD to /home/user/.config
98
98
  ```
99
99
 
100
+ #### Force
101
+
102
+ Forces an action
103
+
104
+ > Currently only implemented on the `-u` flag
105
+
106
+ - Example
107
+
108
+ ```bash
109
+ user:~/.config $ twd -u --force
110
+ TWD File deleted and TWD unset
111
+ ```
112
+
100
113
  # Contribution
101
114
 
102
115
  To set up a dev environment:
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="twd_m4sc0",
5
- version="1.4.0",
5
+ version="1.4.1",
6
6
  packages=find_packages(),
7
7
  entry_points={
8
8
  "console_scripts": [
@@ -42,10 +42,10 @@ def get_absolute_path(path):
42
42
  return os.path.abspath(path)
43
43
 
44
44
  def output_handler(message=None, path=None, output=True, simple_output=False, message_type=0):
45
- if not output:
45
+ if not output or CONFIG["output_behaviour"] == 0:
46
46
  return
47
47
 
48
- if CONFIG["output_behaviour"] == 0:
48
+ if not message and not path:
49
49
  return
50
50
 
51
51
  if message_type == 1:
@@ -90,15 +90,22 @@ def go_to_directory(output=True, simple_output=False):
90
90
  def show_directory(output=True, simple_output=False):
91
91
  TWD = load_directory()
92
92
 
93
- if TWD is None:
93
+ if TWD is None or TWD == '':
94
94
  output_handler("No TWD set", None, output, simple_output)
95
95
  else:
96
96
  output_handler(f"Current TWD: {TWD}", TWD, output, simple_output)
97
97
 
98
- def unset_directory(output=True, simple_output=False):
98
+ def unset_directory(output=True, simple_output=False, force=False):
99
99
  if not os.path.exists(TWD_FILE):
100
100
  output_handler(f"No TWD file found", None, output, simple_output)
101
101
  else:
102
+ if not force:
103
+ output_handler(r'''
104
+ If you want to execute unsetting the current TWD, please use "--force" and run again.
105
+
106
+
107
+ This feature is to prevent accidental execution.''', None, True, False)
108
+ return
102
109
  os.remove(TWD_FILE)
103
110
  output_handler(f"TWD File deleted and TWD unset", None, output, simple_output)
104
111
 
@@ -121,24 +128,27 @@ def main():
121
128
  parser.add_argument('--shell', action='store_true', help="Output shell function for integration")
122
129
  parser.add_argument('--simple-output', action='store_true', help="Only print essential output (new directory, absolute path, etc.)")
123
130
  parser.add_argument('--no-output', action='store_true', help="Prevents the console from sending output")
124
-
131
+ parser.add_argument('-f', '--force', action='store_true', help="Force an action")
125
132
  args = parser.parse_args()
126
133
 
127
134
  output = not args.no_output
128
135
  simple_output = args.simple_output
129
136
 
130
137
  if args.shell:
131
- print('''
138
+ print(r'''
132
139
  function twd() {
133
- output=$(python3 -m twd "$@");
140
+ output=$(python3 -m twd "$@");
134
141
  while IFS= read -r line; do
135
- type=$(echo "$line" | cut -d';' -f1);
136
- message=$(echo "$line" | cut -d';' -f2-);
137
- if [[ "$type" == "1" ]]; then
138
- eval "$message";
139
- else
140
- echo "$message";
141
- fi;
142
+ if [[ -z "$line" ]]; then
143
+ continue;
144
+ fi;
145
+ type=$(echo "$line" | cut -d';' -f1);
146
+ message=$(echo "$line" | cut -d';' -f2-);
147
+ if [[ "$type" == "1" ]]; then
148
+ eval "$message";
149
+ else
150
+ echo "$message";
151
+ fi;
142
152
  done <<< "$output";
143
153
  }
144
154
  ''')
@@ -151,7 +161,8 @@ def main():
151
161
  elif args.list:
152
162
  show_directory(output, simple_output)
153
163
  elif args.unset:
154
- unset_directory(output, simple_output)
164
+ force = args.force
165
+ unset_directory(output, simple_output, force)
155
166
  else:
156
167
  parser.print_help()
157
168
  return 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twd_m4sc0
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A tool to temporarily save and go to a working directory
5
5
  Home-page: https://github.com/m4sc0/twd
6
6
  Author: m4sc0
@@ -35,7 +35,7 @@ pip install twd-m4sc0
35
35
  2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
36
36
 
37
37
  ```bash
38
- eval $(twd --shell)
38
+ eval $(python3 -m twd --shell)
39
39
  ```
40
40
 
41
41
  3. Exit and reopen the terminal or reload using:
@@ -110,6 +110,19 @@ user:~/.config $ twd -s
110
110
  Saved TWD to /home/user/.config
111
111
  ```
112
112
 
113
+ #### Force
114
+
115
+ Forces an action
116
+
117
+ > Currently only implemented on the `-u` flag
118
+
119
+ - Example
120
+
121
+ ```bash
122
+ user:~/.config $ twd -u --force
123
+ TWD File deleted and TWD unset
124
+ ```
125
+
113
126
  # Contribution
114
127
 
115
128
  To set up a dev environment:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes