@@ -9,22 +9,23 @@ import argparse |
| 9 | 9 | import os |
| 10 | 10 | from typing import Optional |
| 11 | 11 | |
| 12 | | -# Package imports |
| 12 | +# Package imports |
| 13 | 13 | from shtick.config import Config |
| 14 | 14 | from shtick.generator import Generator |
| 15 | 15 | from shtick.shells import get_supported_shells |
| 16 | 16 | |
| 17 | + |
| 17 | 18 | def cmd_generate(args) -> None: |
| 18 | 19 | """Generate shell files from config""" |
| 19 | 20 | config_path = args.config or Config.get_default_config_path() |
| 20 | | - |
| 21 | + |
| 21 | 22 | try: |
| 22 | | - config = Config(config_path) |
| 23 | + config = Config(config_path, debug=args.debug) |
| 23 | 24 | config.load() |
| 24 | | - |
| 25 | + |
| 25 | 26 | generator = Generator() |
| 26 | | - generator.generate_all(config) |
| 27 | | - |
| 27 | + generator.generate_all(config, interactive=args.interactive) |
| 28 | + |
| 28 | 29 | except FileNotFoundError as e: |
| 29 | 30 | print(f"Error: {e}") |
| 30 | 31 | print(f"Create a config file at {config_path} first") |
@@ -33,54 +34,58 @@ def cmd_generate(args) -> None: |
| 33 | 34 | print(f"Error: {e}") |
| 34 | 35 | sys.exit(1) |
| 35 | 36 | |
| 37 | + |
| 36 | 38 | def cmd_add(args) -> None: |
| 37 | 39 | """Add an item to the config""" |
| 38 | | - if '=' not in args.assignment: |
| 40 | + if "=" not in args.assignment: |
| 39 | 41 | print("Error: Assignment must be in format key=value") |
| 40 | 42 | sys.exit(1) |
| 41 | | - |
| 42 | | - key, value = args.assignment.split('=', 1) |
| 43 | + |
| 44 | + key, value = args.assignment.split("=", 1) |
| 43 | 45 | key = key.strip() |
| 44 | 46 | value = value.strip() |
| 45 | | - |
| 47 | + |
| 46 | 48 | if not key or not value: |
| 47 | 49 | print("Error: Both key and value must be non-empty") |
| 48 | 50 | sys.exit(1) |
| 49 | | - |
| 51 | + |
| 50 | 52 | config_path = Config.get_default_config_path() |
| 51 | | - |
| 53 | + |
| 52 | 54 | try: |
| 53 | | - config = Config(config_path) |
| 55 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 54 | 56 | # Try to load existing config, create empty if doesn't exist |
| 55 | 57 | try: |
| 56 | 58 | config.load() |
| 57 | 59 | except FileNotFoundError: |
| 58 | 60 | print(f"Creating new config file at {config_path}") |
| 59 | | - |
| 61 | + |
| 60 | 62 | config.add_item(args.type, args.group, key, value) |
| 61 | 63 | config.save() |
| 62 | | - |
| 64 | + |
| 63 | 65 | print(f"Added {args.type} '{key}' = '{value}' to group '{args.group}'") |
| 64 | | - |
| 66 | + |
| 65 | 67 | except Exception as e: |
| 66 | 68 | print(f"Error: {e}") |
| 67 | 69 | sys.exit(1) |
| 68 | 70 | |
| 71 | + |
| 69 | 72 | def cmd_remove(args) -> None: |
| 70 | 73 | """Remove an item from the config""" |
| 71 | 74 | config_path = Config.get_default_config_path() |
| 72 | | - |
| 75 | + |
| 73 | 76 | try: |
| 74 | | - config = Config(config_path) |
| 77 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 75 | 78 | config.load() |
| 76 | | - |
| 79 | + |
| 77 | 80 | # Find matching items |
| 78 | 81 | matches = config.find_items(args.type, args.group, args.search) |
| 79 | | - |
| 82 | + |
| 80 | 83 | if not matches: |
| 81 | | - print(f"No {args.type} items matching '{args.search}' found in group '{args.group}'") |
| 84 | + print( |
| 85 | + f"No {args.type} items matching '{args.search}' found in group '{args.group}'" |
| 86 | + ) |
| 82 | 87 | return |
| 83 | | - |
| 88 | + |
| 84 | 89 | if len(matches) == 1: |
| 85 | 90 | # Exact match, remove it |
| 86 | 91 | item = matches[0] |
@@ -94,13 +99,13 @@ def cmd_remove(args) -> None: |
| 94 | 99 | print(f"Found {len(matches)} matches:") |
| 95 | 100 | for i, item in enumerate(matches, 1): |
| 96 | 101 | print(f" {i}. {item}") |
| 97 | | - |
| 102 | + |
| 98 | 103 | try: |
| 99 | 104 | choice = input("Enter number to remove (or 'q' to quit): ").strip() |
| 100 | | - if choice.lower() == 'q': |
| 105 | + if choice.lower() == "q": |
| 101 | 106 | print("Cancelled") |
| 102 | 107 | return |
| 103 | | - |
| 108 | + |
| 104 | 109 | idx = int(choice) - 1 |
| 105 | 110 | if 0 <= idx < len(matches): |
| 106 | 111 | item = matches[idx] |
@@ -113,7 +118,7 @@ def cmd_remove(args) -> None: |
| 113 | 118 | print("Invalid choice") |
| 114 | 119 | except (ValueError, KeyboardInterrupt): |
| 115 | 120 | print("\nCancelled") |
| 116 | | - |
| 121 | + |
| 117 | 122 | except FileNotFoundError: |
| 118 | 123 | print(f"Config file not found: {config_path}") |
| 119 | 124 | sys.exit(1) |
@@ -121,24 +126,32 @@ def cmd_remove(args) -> None: |
| 121 | 126 | print(f"Error: {e}") |
| 122 | 127 | sys.exit(1) |
| 123 | 128 | |
| 129 | + |
| 124 | 130 | def cmd_activate(args) -> None: |
| 125 | 131 | """Activate a group""" |
| 126 | 132 | config_path = Config.get_default_config_path() |
| 127 | | - |
| 133 | + |
| 128 | 134 | try: |
| 129 | | - config = Config(config_path) |
| 135 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 130 | 136 | config.load() |
| 131 | | - |
| 132 | | - if args.group == 'persistent': |
| 133 | | - print("Error: 'persistent' group is always active and cannot be manually activated") |
| 137 | + |
| 138 | + if args.group == "persistent": |
| 139 | + print( |
| 140 | + "Error: 'persistent' group is always active and cannot be manually activated" |
| 141 | + ) |
| 134 | 142 | return |
| 135 | | - |
| 143 | + |
| 136 | 144 | if config.activate_group(args.group): |
| 137 | | - # Regenerate loader to include newly activated group |
| 145 | + # Regenerate all files to ensure they exist and are up to date |
| 138 | 146 | from shtick.generator import Generator |
| 147 | + |
| 139 | 148 | generator = Generator() |
| 149 | + # Generate shell files for all groups (not just the activated one) |
| 150 | + for group in config.groups: |
| 151 | + generator.generate_for_group(group) |
| 152 | + # Then regenerate the loader to include newly activated group |
| 140 | 153 | generator.generate_loader(config) |
| 141 | | - |
| 154 | + |
| 142 | 155 | print(f"Activated group '{args.group}'") |
| 143 | 156 | print("Changes are now active in new shell sessions") |
| 144 | 157 | else: |
@@ -146,7 +159,7 @@ def cmd_activate(args) -> None: |
| 146 | 159 | available = [g.name for g in config.get_regular_groups()] |
| 147 | 160 | if available: |
| 148 | 161 | print(f"Available groups: {', '.join(available)}") |
| 149 | | - |
| 162 | + |
| 150 | 163 | except FileNotFoundError: |
| 151 | 164 | print(f"Config file not found: {config_path}") |
| 152 | 165 | print("Run 'shtick generate' first or add some items with 'shtick add'") |
@@ -155,29 +168,32 @@ def cmd_activate(args) -> None: |
| 155 | 168 | print(f"Error: {e}") |
| 156 | 169 | sys.exit(1) |
| 157 | 170 | |
| 171 | + |
| 158 | 172 | def cmd_deactivate(args) -> None: |
| 159 | 173 | """Deactivate a group""" |
| 160 | 174 | config_path = Config.get_default_config_path() |
| 161 | | - |
| 175 | + |
| 162 | 176 | try: |
| 163 | | - config = Config(config_path) |
| 177 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 164 | 178 | config.load() |
| 165 | | - |
| 166 | | - if args.group == 'persistent': |
| 179 | + |
| 180 | + if args.group == "persistent": |
| 167 | 181 | print("Error: 'persistent' group cannot be deactivated") |
| 168 | 182 | return |
| 169 | | - |
| 183 | + |
| 170 | 184 | if config.deactivate_group(args.group): |
| 171 | 185 | # Regenerate loader to exclude deactivated group |
| 172 | 186 | from shtick.generator import Generator |
| 187 | + |
| 173 | 188 | generator = Generator() |
| 189 | + # Regenerate loader (no need to regenerate all files for deactivation) |
| 174 | 190 | generator.generate_loader(config) |
| 175 | | - |
| 191 | + |
| 176 | 192 | print(f"Deactivated group '{args.group}'") |
| 177 | 193 | print("Changes will take effect in new shell sessions") |
| 178 | 194 | else: |
| 179 | 195 | print(f"Group '{args.group}' was not active") |
| 180 | | - |
| 196 | + |
| 181 | 197 | except FileNotFoundError: |
| 182 | 198 | print(f"Config file not found: {config_path}") |
| 183 | 199 | sys.exit(1) |
@@ -185,36 +201,40 @@ def cmd_deactivate(args) -> None: |
| 185 | 201 | print(f"Error: {e}") |
| 186 | 202 | sys.exit(1) |
| 187 | 203 | |
| 204 | + |
| 188 | 205 | def cmd_list(args) -> None: |
| 189 | 206 | """List current configuration""" |
| 190 | 207 | config_path = Config.get_default_config_path() |
| 191 | | - |
| 208 | + |
| 192 | 209 | try: |
| 193 | | - config = Config(config_path) |
| 210 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 194 | 211 | config.load() |
| 195 | | - |
| 212 | + |
| 196 | 213 | if not config.groups: |
| 197 | 214 | print("No groups configured") |
| 198 | 215 | return |
| 199 | | - |
| 216 | + |
| 200 | 217 | persistent_group = config.get_persistent_group() |
| 201 | 218 | regular_groups = config.get_regular_groups() |
| 202 | 219 | active_groups = config.load_active_groups() |
| 203 | | - |
| 220 | + |
| 204 | 221 | if args.long: |
| 205 | 222 | # Long format - detailed line-by-line |
| 206 | 223 | _print_detailed_list(persistent_group, regular_groups, active_groups) |
| 207 | 224 | else: |
| 208 | 225 | # Default tabular format |
| 209 | 226 | _print_tabular_list(persistent_group, regular_groups, active_groups) |
| 210 | | - |
| 227 | + |
| 211 | 228 | except FileNotFoundError: |
| 212 | 229 | print(f"Config file not found: {config_path}") |
| 213 | | - print("Use 'shtick add' to create entries or 'shtick generate' with a config file") |
| 230 | + print( |
| 231 | + "Use 'shtick add' to create entries or 'shtick generate' with a config file" |
| 232 | + ) |
| 214 | 233 | except Exception as e: |
| 215 | 234 | print(f"Error: {e}") |
| 216 | 235 | sys.exit(1) |
| 217 | 236 | |
| 237 | + |
| 218 | 238 | def _print_detailed_list(persistent_group, regular_groups, active_groups) -> None: |
| 219 | 239 | """Print detailed line-by-line list format""" |
| 220 | 240 | # Show persistent group first |
@@ -233,33 +253,34 @@ def _print_detailed_list(persistent_group, regular_groups, active_groups) -> Non |
| 233 | 253 | for key, value in persistent_group.functions.items(): |
| 234 | 254 | print(f" {key} = {value}") |
| 235 | 255 | print() |
| 236 | | - |
| 256 | + |
| 237 | 257 | # Show regular groups |
| 238 | 258 | for group in regular_groups: |
| 239 | 259 | status = " (ACTIVE)" if group.name in active_groups else " (inactive)" |
| 240 | 260 | print(f"Group: {group.name}{status}") |
| 241 | | - |
| 261 | + |
| 242 | 262 | if group.aliases: |
| 243 | 263 | print(f" Aliases ({len(group.aliases)}):") |
| 244 | 264 | for key, value in group.aliases.items(): |
| 245 | 265 | print(f" {key} = {value}") |
| 246 | | - |
| 266 | + |
| 247 | 267 | if group.env_vars: |
| 248 | 268 | print(f" Environment Variables ({len(group.env_vars)}):") |
| 249 | 269 | for key, value in group.env_vars.items(): |
| 250 | 270 | print(f" {key} = {value}") |
| 251 | | - |
| 271 | + |
| 252 | 272 | if group.functions: |
| 253 | 273 | print(f" Functions ({len(group.functions)}):") |
| 254 | 274 | for key, value in group.functions.items(): |
| 255 | 275 | print(f" {key} = {value}") |
| 256 | 276 | print() |
| 257 | 277 | |
| 278 | + |
| 258 | 279 | def _print_tabular_list(persistent_group, regular_groups, active_groups) -> None: |
| 259 | 280 | """Print compact tabular list format""" |
| 260 | 281 | # Collect all items for tabular display |
| 261 | 282 | items = [] |
| 262 | | - |
| 283 | + |
| 263 | 284 | # Add persistent items |
| 264 | 285 | if persistent_group: |
| 265 | 286 | for key, value in persistent_group.aliases.items(): |
@@ -268,54 +289,58 @@ def _print_tabular_list(persistent_group, regular_groups, active_groups) -> None |
| 268 | 289 | items.append(("persistent", "env", key, value, "PERSISTENT")) |
| 269 | 290 | for key, value in persistent_group.functions.items(): |
| 270 | 291 | items.append(("persistent", "function", key, value, "PERSISTENT")) |
| 271 | | - |
| 292 | + |
| 272 | 293 | # Add regular group items |
| 273 | 294 | for group in regular_groups: |
| 274 | 295 | status = "ACTIVE" if group.name in active_groups else "inactive" |
| 275 | | - |
| 296 | + |
| 276 | 297 | for key, value in group.aliases.items(): |
| 277 | 298 | items.append((group.name, "alias", key, value, status)) |
| 278 | 299 | for key, value in group.env_vars.items(): |
| 279 | 300 | items.append((group.name, "env", key, value, status)) |
| 280 | 301 | for key, value in group.functions.items(): |
| 281 | 302 | items.append((group.name, "function", key, value, status)) |
| 282 | | - |
| 303 | + |
| 283 | 304 | if not items: |
| 284 | 305 | print("No items configured") |
| 285 | 306 | return |
| 286 | | - |
| 307 | + |
| 287 | 308 | # Calculate column widths |
| 288 | 309 | max_group = max(len(item[0]) for item in items) |
| 289 | 310 | max_type = max(len(item[1]) for item in items) |
| 290 | 311 | max_key = max(len(item[2]) for item in items) |
| 291 | 312 | max_value = max(min(len(item[3]), 50) for item in items) # Limit value column width |
| 292 | 313 | max_status = max(len(item[4]) for item in items) |
| 293 | | - |
| 314 | + |
| 294 | 315 | # Ensure minimum widths |
| 295 | 316 | max_group = max(max_group, 5) # "Group" |
| 296 | | - max_type = max(max_type, 4) # "Type" |
| 297 | | - max_key = max(max_key, 3) # "Key" |
| 317 | + max_type = max(max_type, 4) # "Type" |
| 318 | + max_key = max(max_key, 3) # "Key" |
| 298 | 319 | max_value = max(max_value, 5) # "Value" |
| 299 | | - max_status = max(max_status, 6) # "Status" |
| 300 | | - |
| 320 | + max_status = max(max_status, 6) # "Status" |
| 321 | + |
| 301 | 322 | # Print header |
| 302 | 323 | header = f"{'Group':<{max_group}} {'Type':<{max_type}} {'Key':<{max_key}} {'Value':<{max_value}} {'Status':<{max_status}}" |
| 303 | 324 | print(header) |
| 304 | 325 | print("-" * len(header)) |
| 305 | | - |
| 326 | + |
| 306 | 327 | # Print items |
| 307 | 328 | for group, item_type, key, value, status in items: |
| 308 | 329 | # Truncate long values with ellipsis |
| 309 | | - display_value = value if len(value) <= max_value else value[:max_value-3] + "..." |
| 310 | | - |
| 311 | | - print(f"{group:<{max_group}} {item_type:<{max_type}} {key:<{max_key}} {display_value:<{max_value}} {status:<{max_status}}") |
| 312 | | - |
| 330 | + display_value = ( |
| 331 | + value if len(value) <= max_value else value[: max_value - 3] + "..." |
| 332 | + ) |
| 333 | + |
| 334 | + print( |
| 335 | + f"{group:<{max_group}} {item_type:<{max_type}} {key:<{max_key}} {display_value:<{max_value}} {status:<{max_status}}" |
| 336 | + ) |
| 337 | + |
| 313 | 338 | # Print summary |
| 314 | 339 | print() |
| 315 | 340 | total_items = len(items) |
| 316 | 341 | active_items = len([item for item in items if item[4] in ["ACTIVE", "PERSISTENT"]]) |
| 317 | 342 | print(f"Total: {total_items} items ({active_items} active)") |
| 318 | | - |
| 343 | + |
| 319 | 344 | # Show available commands |
| 320 | 345 | print() |
| 321 | 346 | print("Use 'shtick list -l' for detailed view") |
@@ -324,10 +349,11 @@ def _print_tabular_list(persistent_group, regular_groups, active_groups) -> None |
| 324 | 349 | print(f"Activate groups with: shtick activate <group>") |
| 325 | 350 | print(f"Inactive groups: {', '.join(sorted(inactive_groups))}") |
| 326 | 351 | |
| 352 | + |
| 327 | 353 | def cmd_shells(args) -> None: |
| 328 | 354 | """List supported shells""" |
| 329 | 355 | shells = sorted(get_supported_shells()) |
| 330 | | - |
| 356 | + |
| 331 | 357 | if args.long: |
| 332 | 358 | # Long format - one per line with descriptions |
| 333 | 359 | print("Supported shells:") |
@@ -337,34 +363,36 @@ def cmd_shells(args) -> None: |
| 337 | 363 | # Default columnar format (like ls) |
| 338 | 364 | _print_shells_columns(shells) |
| 339 | 365 | |
| 366 | + |
| 340 | 367 | def _print_shells_columns(shells) -> None: |
| 341 | 368 | """Print shells in columns like ls output""" |
| 342 | 369 | if not shells: |
| 343 | 370 | print("No shells configured") |
| 344 | 371 | return |
| 345 | | - |
| 372 | + |
| 346 | 373 | # Try to get terminal width, fallback to 80 |
| 347 | 374 | try: |
| 348 | 375 | import shutil |
| 376 | + |
| 349 | 377 | terminal_width = shutil.get_terminal_size().columns |
| 350 | 378 | except: |
| 351 | 379 | terminal_width = 80 |
| 352 | | - |
| 380 | + |
| 353 | 381 | # Find the longest shell name |
| 354 | 382 | max_shell_length = max(len(shell) for shell in shells) |
| 355 | | - |
| 383 | + |
| 356 | 384 | # Add some padding |
| 357 | 385 | column_width = max_shell_length + 2 |
| 358 | | - |
| 386 | + |
| 359 | 387 | # Calculate how many columns we can fit |
| 360 | 388 | columns = max(1, terminal_width // column_width) |
| 361 | | - |
| 389 | + |
| 362 | 390 | # Calculate number of rows needed |
| 363 | 391 | rows = (len(shells) + columns - 1) // columns |
| 364 | | - |
| 392 | + |
| 365 | 393 | print(f"Supported shells ({len(shells)} total):") |
| 366 | 394 | print() |
| 367 | | - |
| 395 | + |
| 368 | 396 | # Print shells in columns |
| 369 | 397 | for row in range(rows): |
| 370 | 398 | line = "" |
@@ -375,52 +403,59 @@ def _print_shells_columns(shells) -> None: |
| 375 | 403 | line += f"{shell:<{column_width}}" |
| 376 | 404 | print(line.rstrip()) |
| 377 | 405 | |
| 406 | + |
| 378 | 407 | def cmd_status(args) -> None: |
| 379 | 408 | """Show status of groups and active state""" |
| 380 | 409 | config_path = Config.get_default_config_path() |
| 381 | | - |
| 410 | + |
| 382 | 411 | try: |
| 383 | | - config = Config(config_path) |
| 412 | + config = Config(config_path, debug=getattr(args, "debug", False)) |
| 384 | 413 | config.load() |
| 385 | | - |
| 414 | + |
| 386 | 415 | persistent_group = config.get_persistent_group() |
| 387 | 416 | regular_groups = config.get_regular_groups() |
| 388 | 417 | active_groups = config.load_active_groups() |
| 389 | | - |
| 418 | + |
| 390 | 419 | print("Shtick Status") |
| 391 | 420 | print("=" * 40) |
| 392 | | - |
| 421 | + |
| 393 | 422 | # Show persistent group |
| 394 | 423 | if persistent_group: |
| 395 | | - total_persistent = len(persistent_group.aliases) + len(persistent_group.env_vars) + len(persistent_group.functions) |
| 424 | + total_persistent = ( |
| 425 | + len(persistent_group.aliases) |
| 426 | + + len(persistent_group.env_vars) |
| 427 | + + len(persistent_group.functions) |
| 428 | + ) |
| 396 | 429 | print(f"Persistent (always active): {total_persistent} items") |
| 397 | 430 | else: |
| 398 | 431 | print("Persistent: No items") |
| 399 | | - |
| 432 | + |
| 400 | 433 | print() |
| 401 | | - |
| 434 | + |
| 402 | 435 | # Show regular groups |
| 403 | 436 | if regular_groups: |
| 404 | 437 | print("Available Groups:") |
| 405 | 438 | for group in regular_groups: |
| 406 | 439 | status = "ACTIVE" if group.name in active_groups else "inactive" |
| 407 | | - total_items = len(group.aliases) + len(group.env_vars) + len(group.functions) |
| 440 | + total_items = ( |
| 441 | + len(group.aliases) + len(group.env_vars) + len(group.functions) |
| 442 | + ) |
| 408 | 443 | print(f" {group.name}: {total_items} items ({status})") |
| 409 | 444 | else: |
| 410 | 445 | print("No regular groups configured") |
| 411 | | - |
| 446 | + |
| 412 | 447 | print() |
| 413 | | - |
| 448 | + |
| 414 | 449 | # Show summary |
| 415 | 450 | if active_groups: |
| 416 | 451 | print(f"Currently active: {', '.join(active_groups)}") |
| 417 | 452 | else: |
| 418 | 453 | print("No groups currently active") |
| 419 | | - |
| 454 | + |
| 420 | 455 | print() |
| 421 | 456 | print("To activate a group: shtick activate <group>") |
| 422 | 457 | print("To deactivate a group: shtick deactivate <group>") |
| 423 | | - |
| 458 | + |
| 424 | 459 | except FileNotFoundError: |
| 425 | 460 | print(f"Config file not found: {config_path}") |
| 426 | 461 | print("No configuration exists yet") |
@@ -428,75 +463,98 @@ def cmd_status(args) -> None: |
| 428 | 463 | print(f"Error: {e}") |
| 429 | 464 | sys.exit(1) |
| 430 | 465 | |
| 466 | + |
| 431 | 467 | def main(): |
| 432 | 468 | """Main CLI entry point""" |
| 433 | 469 | parser = argparse.ArgumentParser( |
| 434 | 470 | description="shtick - Generate shell configuration files from TOML" |
| 435 | 471 | ) |
| 436 | | - |
| 437 | | - subparsers = parser.add_subparsers(dest='command', help='Available commands') |
| 438 | | - |
| 472 | + |
| 473 | + # Global flags |
| 474 | + parser.add_argument("--debug", action="store_true", help="Enable debug output") |
| 475 | + |
| 476 | + subparsers = parser.add_subparsers(dest="command", help="Available commands") |
| 477 | + |
| 439 | 478 | # Generate command |
| 440 | | - gen_parser = subparsers.add_parser('generate', help='Generate shell files from config') |
| 441 | | - gen_parser.add_argument('config', nargs='?', help='Path to config TOML file') |
| 442 | | - |
| 443 | | - # Add command |
| 444 | | - add_parser = subparsers.add_parser('add', help='Add an item to config') |
| 445 | | - add_parser.add_argument('type', choices=['alias', 'env', 'function'], |
| 446 | | - help='Type of item to add') |
| 447 | | - add_parser.add_argument('group', help='Group name') |
| 448 | | - add_parser.add_argument('assignment', help='Assignment in format key=value') |
| 449 | | - |
| 479 | + gen_parser = subparsers.add_parser( |
| 480 | + "generate", help="Generate shell files from config" |
| 481 | + ) |
| 482 | + gen_parser.add_argument("config", nargs="?", help="Path to config TOML file") |
| 483 | + gen_parser.add_argument( |
| 484 | + "-i", |
| 485 | + "--interactive", |
| 486 | + action="store_true", |
| 487 | + help="Interactive shell selection for sourcing instructions", |
| 488 | + ) |
| 489 | + |
| 490 | + # Add command |
| 491 | + add_parser = subparsers.add_parser("add", help="Add an item to config") |
| 492 | + add_parser.add_argument( |
| 493 | + "type", choices=["alias", "env", "function"], help="Type of item to add" |
| 494 | + ) |
| 495 | + add_parser.add_argument("group", help="Group name") |
| 496 | + add_parser.add_argument("assignment", help="Assignment in format key=value") |
| 497 | + |
| 450 | 498 | # Remove command |
| 451 | | - rm_parser = subparsers.add_parser('remove', help='Remove an item from config') |
| 452 | | - rm_parser.add_argument('type', choices=['alias', 'env', 'function'], |
| 453 | | - help='Type of item to remove') |
| 454 | | - rm_parser.add_argument('group', help='Group name') |
| 455 | | - rm_parser.add_argument('search', help='Search term (fuzzy match)') |
| 456 | | - |
| 499 | + rm_parser = subparsers.add_parser("remove", help="Remove an item from config") |
| 500 | + rm_parser.add_argument( |
| 501 | + "type", choices=["alias", "env", "function"], help="Type of item to remove" |
| 502 | + ) |
| 503 | + rm_parser.add_argument("group", help="Group name") |
| 504 | + rm_parser.add_argument("search", help="Search term (fuzzy match)") |
| 505 | + |
| 457 | 506 | # Activate command |
| 458 | | - activate_parser = subparsers.add_parser('activate', help='Activate a group') |
| 459 | | - activate_parser.add_argument('group', help='Group name to activate') |
| 460 | | - |
| 461 | | - # Deactivate command |
| 462 | | - deactivate_parser = subparsers.add_parser('deactivate', help='Deactivate a group') |
| 463 | | - deactivate_parser.add_argument('group', help='Group name to deactivate') |
| 464 | | - |
| 507 | + activate_parser = subparsers.add_parser("activate", help="Activate a group") |
| 508 | + activate_parser.add_argument("group", help="Group name to activate") |
| 509 | + |
| 510 | + # Deactivate command |
| 511 | + deactivate_parser = subparsers.add_parser("deactivate", help="Deactivate a group") |
| 512 | + deactivate_parser.add_argument("group", help="Group name to deactivate") |
| 513 | + |
| 465 | 514 | # Status command |
| 466 | | - status_parser = subparsers.add_parser('status', help='Show status of groups') |
| 467 | | - |
| 515 | + status_parser = subparsers.add_parser("status", help="Show status of groups") |
| 516 | + |
| 468 | 517 | # List command |
| 469 | | - list_parser = subparsers.add_parser('list', help='List current configuration') |
| 470 | | - list_parser.add_argument('-l', '--long', action='store_true', |
| 471 | | - help='Show detailed line-by-line format instead of table') |
| 472 | | - |
| 518 | + list_parser = subparsers.add_parser("list", help="List current configuration") |
| 519 | + list_parser.add_argument( |
| 520 | + "-l", |
| 521 | + "--long", |
| 522 | + action="store_true", |
| 523 | + help="Show detailed line-by-line format instead of table", |
| 524 | + ) |
| 525 | + |
| 473 | 526 | # Shells command |
| 474 | | - shells_parser = subparsers.add_parser('shells', help='List supported shells') |
| 475 | | - shells_parser.add_argument('-l', '--long', action='store_true', |
| 476 | | - help='Show one shell per line instead of columns') |
| 477 | | - |
| 527 | + shells_parser = subparsers.add_parser("shells", help="List supported shells") |
| 528 | + shells_parser.add_argument( |
| 529 | + "-l", |
| 530 | + "--long", |
| 531 | + action="store_true", |
| 532 | + help="Show one shell per line instead of columns", |
| 533 | + ) |
| 534 | + |
| 478 | 535 | args = parser.parse_args() |
| 479 | | - |
| 536 | + |
| 480 | 537 | if not args.command: |
| 481 | 538 | parser.print_help() |
| 482 | 539 | sys.exit(1) |
| 483 | | - |
| 484 | | - if args.command == 'generate': |
| 540 | + |
| 541 | + if args.command == "generate": |
| 485 | 542 | cmd_generate(args) |
| 486 | | - elif args.command == 'add': |
| 543 | + elif args.command == "add": |
| 487 | 544 | cmd_add(args) |
| 488 | | - elif args.command == 'remove': |
| 545 | + elif args.command == "remove": |
| 489 | 546 | cmd_remove(args) |
| 490 | | - elif args.command == 'activate': |
| 547 | + elif args.command == "activate": |
| 491 | 548 | cmd_activate(args) |
| 492 | | - elif args.command == 'deactivate': |
| 549 | + elif args.command == "deactivate": |
| 493 | 550 | cmd_deactivate(args) |
| 494 | | - elif args.command == 'status': |
| 551 | + elif args.command == "status": |
| 495 | 552 | cmd_status(args) |
| 496 | | - elif args.command == 'list': |
| 553 | + elif args.command == "list": |
| 497 | 554 | cmd_list(args) |
| 498 | | - elif args.command == 'shells': |
| 555 | + elif args.command == "shells": |
| 499 | 556 | cmd_shells(args) |
| 500 | 557 | |
| 501 | | -if __name__ == '__main__': |
| 502 | | - main() |
| 558 | + |
| 559 | +if __name__ == "__main__": |
| 560 | + main() |