command-manager-util 1.0.0__tar.gz → 1.1.0__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.4
2
2
  Name: command-manager-util
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Manages useful commands in one place using fzf
5
5
  Home-page: https://github.com/Sahaj001/Script-Manager
6
6
  Author: Sahaj Pratap Singh
@@ -24,7 +24,7 @@ def read_file():
24
24
 
25
25
  setup(
26
26
  name="command-manager-util",
27
- version="1.0.0",
27
+ version="1.1.0",
28
28
  description="Manages useful commands in one place using fzf",
29
29
  long_description=read_file(),
30
30
  long_description_content_type="text/markdown",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: command-manager-util
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Manages useful commands in one place using fzf
5
5
  Home-page: https://github.com/Sahaj001/Script-Manager
6
6
  Author: Sahaj Pratap Singh
@@ -60,21 +60,41 @@ def add_new_command(commands, category=None):
60
60
  print(f"echo '✅ Added to {target_cat}'")
61
61
 
62
62
 
63
- def delete_category(commands):
64
- """Handles wiping an entire category."""
65
- categories = sorted(list(set(c[0] for c in commands)))
66
- if not categories:
67
- print("echo 'No categories to delete!'")
68
- return commands
69
-
70
- cat_to_wipe = run_fzf(categories, "SELECT CATEGORY TO WIPE ENTIRELY")
71
- if cat_to_wipe:
72
- conf = prompt_user(f"Delete ALL commands in [{cat_to_wipe}]? (y/n)")
73
- if conf.lower() == "y":
74
- commands = [c for c in commands if c[0] != cat_to_wipe]
75
- save_commands(commands)
76
- print(f"echo '❌ Category [{cat_to_wipe}] deleted!'")
77
- return commands
63
+ def delete_logic(commands, category=None):
64
+ """Handles deletion of an entire category or a single command."""
65
+ # 1. DELETE WHOLE CATEGORY (if no specific category is passed)
66
+ if category is None:
67
+ categories = sorted(list(set(c[0] for c in commands)))
68
+ if not categories:
69
+ print("echo 'No categories to delete!'")
70
+ return
71
+
72
+ cat_to_wipe = run_fzf(categories, "SELECT CATEGORY TO WIPE ENTIRELY")
73
+ if cat_to_wipe:
74
+ conf = prompt_user(f"Delete ALL commands in [{cat_to_wipe}]? (y/n)")
75
+ if conf and conf.lower() == "y":
76
+ updated_commands = [c for c in commands if c[0] != cat_to_wipe]
77
+ save_commands(updated_commands)
78
+ print(f"echo '❌ Category [{cat_to_wipe}] deleted!'")
79
+ return
80
+
81
+ # 2. DELETE SINGLE COMMAND (if category is provided)
82
+ sub_cmds = [c for c in commands if c[0] == category]
83
+ cat_raw = [f"{c[1]} | {c[2]}" for c in sub_cmds]
84
+
85
+ to_delete_display = run_fzf(cat_raw, f"SELECT COMMAND TO DELETE FROM {category}")
86
+
87
+ if to_delete_display:
88
+ parts = [x.strip() for x in to_delete_display.split("|")]
89
+ if len(parts) >= 2:
90
+ d_name, d_cmd = parts[0], parts[1]
91
+ updated_commands = [
92
+ c
93
+ for c in commands
94
+ if not (c[0] == category and c[1] == d_name and c[2] == d_cmd)
95
+ ]
96
+ save_commands(updated_commands)
97
+ print(f"echo '❌ Deleted [{d_name}] from {category}'")
78
98
 
79
99
 
80
100
  def main():
@@ -95,13 +115,16 @@ def main():
95
115
  return
96
116
 
97
117
  if category == "[- Delete Category]":
98
- delete_category(commands)
118
+ delete_logic(commands)
99
119
  return
100
120
 
101
121
  # 2. COMMAND LEVEL
102
122
  sub_cmds = [c for c in commands if c[0] == category]
103
123
  cmd_options = [f"{c[1]}|{c[2]}" for c in sub_cmds]
104
- cmd_options += [f"[+ Add Command to {category}]"]
124
+ cmd_options += [
125
+ f"[+ Add Command to {category}]",
126
+ f"[- Delete Command from {category}]",
127
+ ]
105
128
 
106
129
  selection = run_fzf(cmd_options, f"Commands in {category}")
107
130
 
@@ -112,6 +135,11 @@ def main():
112
135
  add_new_command(commands, category)
113
136
  return
114
137
 
138
+ # --- NEW LOGIC CALL ---
139
+ if selection == f"[- Delete Command from {category}]":
140
+ delete_logic(commands, category)
141
+ return
142
+
115
143
  # 3. EXECUTE
116
- print(selection.split("|", maxsplit=-1)[-1])
144
+ print(selection.split("|", maxsplit=2)[-1])
117
145
  break