scriptvault 0.0.1__tar.gz → 0.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.
Files changed (27) hide show
  1. {scriptvault-0.0.1/src/scriptvault.egg-info → scriptvault-0.1.0}/PKG-INFO +81 -8
  2. {scriptvault-0.0.1 → scriptvault-0.1.0}/README.md +80 -7
  3. {scriptvault-0.0.1 → scriptvault-0.1.0}/pyproject.toml +1 -1
  4. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/cli.py +244 -53
  5. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/run.py +31 -14
  6. scriptvault-0.1.0/src/scriptvault/vault.py +649 -0
  7. {scriptvault-0.0.1 → scriptvault-0.1.0/src/scriptvault.egg-info}/PKG-INFO +81 -8
  8. scriptvault-0.0.1/src/scriptvault/vault.py +0 -326
  9. {scriptvault-0.0.1 → scriptvault-0.1.0}/LICENSE +0 -0
  10. {scriptvault-0.0.1 → scriptvault-0.1.0}/setup.cfg +0 -0
  11. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/__init__.py +0 -0
  12. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/__main__.py +0 -0
  13. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/envfile.py +0 -0
  14. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/templates.py +0 -0
  15. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault/term.py +0 -0
  16. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault.egg-info/SOURCES.txt +0 -0
  17. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault.egg-info/dependency_links.txt +0 -0
  18. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault.egg-info/entry_points.txt +0 -0
  19. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault.egg-info/requires.txt +0 -0
  20. {scriptvault-0.0.1 → scriptvault-0.1.0}/src/scriptvault.egg-info/top_level.txt +0 -0
  21. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_add.py +0 -0
  22. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_completion.py +0 -0
  23. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_edit.py +0 -0
  24. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_init.py +0 -0
  25. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_list.py +0 -0
  26. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_real.py +0 -0
  27. {scriptvault-0.0.1 → scriptvault-0.1.0}/tests/test_run.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptvault
3
- Version: 0.0.1
3
+ Version: 0.1.0
4
4
  Summary: Store and run project commands in a hidden vault directory
5
5
  Author: Majwt
6
6
  License-Expression: MIT
@@ -71,18 +71,50 @@ sv list
71
71
  ## Vault layout
72
72
 
73
73
  ```text
74
- .sv/
75
- vault.toml
76
- .env
77
- scripts/
78
- hello.sh
79
- hello.env
74
+ .project/
75
+ .sv/
76
+ vault.toml
77
+ .env
78
+ scripts/
79
+ hello.sh
80
+ hello.env
81
+ includes/
82
+ c-hello/
83
+ .sv/
84
+ vault.toml
85
+ scripts/
86
+ build.sh
80
87
  ```
81
88
 
82
- - `vault.toml` defines inline scripts and orchestrations.
89
+ - `vault.toml` defines inline scripts, orchestrations, and nested vault includes.
83
90
  - `.env` is the global dotenv file.
84
91
  - `scripts/*.sh` are executable file scripts.
85
92
  - `scripts/NAME.env` is the per-script dotenv file.
93
+ - `[include.NAME]` sections load scripts from nested vaults (see below).
94
+
95
+ ### Nested Vaults
96
+
97
+ Include scripts from subdirectories:
98
+
99
+ ```toml
100
+ [vault]
101
+ name = "myproject"
102
+
103
+ [include.c-hello]
104
+ path = "includes/c-hello/.sv/vault.toml"
105
+
106
+ [include.shell]
107
+ path = "includes/shell/.sv/vault.toml"
108
+ ```
109
+
110
+ Run scripts with the include name prefix:
111
+
112
+ ```bash
113
+ sv run c-hello build
114
+ sv c-hello build
115
+ ```
116
+
117
+ Implied run (`sv deploy`) only works for root vault scripts.
86
118
 
87
119
  ## Scripts
88
120
 
@@ -228,3 +260,44 @@ sv completion fish | source
228
260
  sv help
229
261
  sv --version
230
262
  ```
263
+
264
+ ## Documentation
265
+
266
+ For detailed guides and documentation:
267
+
268
+ - [Vault Activation](docs/VAULT_ACTIVATION.md) - How to activate specific vaults
269
+ - [Nested Vaults](docs/IMPLEMENTATION_SUMMARY.md) - Working with nested vaults
270
+ - [Completion Guide](docs/COMPLETION_REPORT.md) - Shell completion details
271
+
272
+ ---
273
+
274
+ ## Root Vault Activation
275
+
276
+ When running `sv` from any subdirectory, it automatically uses the root `.sv` directory.
277
+
278
+ See [Vault Activation](docs/VAULT_ACTIVATION.md) for detailed information.
279
+
280
+ ## Orchestration with Nested Scripts
281
+
282
+ Orchestrations can reference scripts from included vaults.
283
+
284
+ See [Nested Vaults](docs/IMPLEMENTATION_SUMMARY.md) for examples.
285
+
286
+ ## Shell Completion
287
+
288
+ Generate shell completion scripts:
289
+
290
+ ```bash
291
+ # Auto-detect from SHELL environment variable
292
+ sv completion $shell | source
293
+
294
+ # Specify shell explicitly
295
+ sv completion bash | source
296
+ sv completion zsh | source
297
+ sv completion fish | source
298
+
299
+ # Use full path
300
+ sv completion /usr/bin/bash | source
301
+ ```
302
+
303
+ See [Shell Completion](docs/COMPLETION_REPORT.md) for details.
@@ -51,18 +51,50 @@ sv list
51
51
  ## Vault layout
52
52
 
53
53
  ```text
54
- .sv/
55
- vault.toml
56
- .env
57
- scripts/
58
- hello.sh
59
- hello.env
54
+ .project/
55
+ .sv/
56
+ vault.toml
57
+ .env
58
+ scripts/
59
+ hello.sh
60
+ hello.env
61
+ includes/
62
+ c-hello/
63
+ .sv/
64
+ vault.toml
65
+ scripts/
66
+ build.sh
60
67
  ```
61
68
 
62
- - `vault.toml` defines inline scripts and orchestrations.
69
+ - `vault.toml` defines inline scripts, orchestrations, and nested vault includes.
63
70
  - `.env` is the global dotenv file.
64
71
  - `scripts/*.sh` are executable file scripts.
65
72
  - `scripts/NAME.env` is the per-script dotenv file.
73
+ - `[include.NAME]` sections load scripts from nested vaults (see below).
74
+
75
+ ### Nested Vaults
76
+
77
+ Include scripts from subdirectories:
78
+
79
+ ```toml
80
+ [vault]
81
+ name = "myproject"
82
+
83
+ [include.c-hello]
84
+ path = "includes/c-hello/.sv/vault.toml"
85
+
86
+ [include.shell]
87
+ path = "includes/shell/.sv/vault.toml"
88
+ ```
89
+
90
+ Run scripts with the include name prefix:
91
+
92
+ ```bash
93
+ sv run c-hello build
94
+ sv c-hello build
95
+ ```
96
+
97
+ Implied run (`sv deploy`) only works for root vault scripts.
66
98
 
67
99
  ## Scripts
68
100
 
@@ -208,3 +240,44 @@ sv completion fish | source
208
240
  sv help
209
241
  sv --version
210
242
  ```
243
+
244
+ ## Documentation
245
+
246
+ For detailed guides and documentation:
247
+
248
+ - [Vault Activation](docs/VAULT_ACTIVATION.md) - How to activate specific vaults
249
+ - [Nested Vaults](docs/IMPLEMENTATION_SUMMARY.md) - Working with nested vaults
250
+ - [Completion Guide](docs/COMPLETION_REPORT.md) - Shell completion details
251
+
252
+ ---
253
+
254
+ ## Root Vault Activation
255
+
256
+ When running `sv` from any subdirectory, it automatically uses the root `.sv` directory.
257
+
258
+ See [Vault Activation](docs/VAULT_ACTIVATION.md) for detailed information.
259
+
260
+ ## Orchestration with Nested Scripts
261
+
262
+ Orchestrations can reference scripts from included vaults.
263
+
264
+ See [Nested Vaults](docs/IMPLEMENTATION_SUMMARY.md) for examples.
265
+
266
+ ## Shell Completion
267
+
268
+ Generate shell completion scripts:
269
+
270
+ ```bash
271
+ # Auto-detect from SHELL environment variable
272
+ sv completion $shell | source
273
+
274
+ # Specify shell explicitly
275
+ sv completion bash | source
276
+ sv completion zsh | source
277
+ sv completion fish | source
278
+
279
+ # Use full path
280
+ sv completion /usr/bin/bash | source
281
+ ```
282
+
283
+ See [Shell Completion](docs/COMPLETION_REPORT.md) for details.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scriptvault"
7
- version = "0.0.1"
7
+ version = "0.1.0"
8
8
  description = "Store and run project commands in a hidden vault directory"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -23,7 +23,7 @@ from .vault import (
23
23
  load_vault,
24
24
  )
25
25
 
26
- COMMANDS = ("add", "completion", "edit", "help", "init", "list", "run")
26
+ COMMANDS = ("add", "activate", "deactivate", "completion", "edit", "help", "init", "list", "run")
27
27
  BUILTIN_COMMANDS = set(COMMANDS) | {"__names"}
28
28
  RESERVED_NAMES = BUILTIN_COMMANDS | {"config", "env"}
29
29
 
@@ -111,60 +111,104 @@ def cmd_list(args: argparse.Namespace) -> int:
111
111
 
112
112
  if args.json:
113
113
  json.dump(
114
- [_target_json(target) for target in vault.targets.values()],
114
+ {
115
+ "vault": vault.name,
116
+ "scripts": [_target_json(target) for target in vault.targets.values()],
117
+ "includes": {
118
+ name: {
119
+ "path": str(vault._nested_vaults[name].root),
120
+ "scripts": list(vault._nested_vaults[name].scripts.keys()),
121
+ }
122
+ for name in vault._nested_vaults
123
+ },
124
+ },
115
125
  sys.stdout,
116
126
  indent=2,
117
127
  )
118
128
  sys.stdout.write("\n")
119
129
  return 0
120
130
 
121
- rows = [
122
- (
123
- name,
124
- "orchestration" if isinstance(target, Orchestration) else "script",
125
- target.description,
126
- )
127
- for name, target in vault.targets.items()
128
- ]
129
- if not rows:
130
- print("no scripts or orchestrations defined")
131
- return 0
131
+ # Show nested structure
132
+ print(f"Root vault: {vault.name}")
133
+
134
+ # Root scripts only (exclude nested vault names)
135
+ root_scripts = [name for name in vault.scripts.keys() if name not in vault._nested_vaults]
136
+ if root_scripts:
137
+ print(f" Scripts: {', '.join(root_scripts)}")
138
+
139
+ if vault._nested_vaults:
140
+ print(f"\nIncluded vaults:")
141
+ for include_name, nested_vault in vault._nested_vaults.items():
142
+ scripts = [name for name in nested_vault.scripts.keys() if name not in vault._nested_vaults]
143
+ if scripts:
144
+ print(f" {include_name}: {', '.join(scripts)}")
145
+
146
+ # If --nested flag is set, show more details
147
+ if args.nested:
148
+ print("\nAll scripts (including nested):")
149
+ for name, target in vault.targets.items():
150
+ print(f" {name}: {target.description}")
132
151
 
133
- header = ("NAME", "KIND", "DESCRIPTION")
134
- widths = [
135
- max(len(header[i]), *(len(row[i]) for row in rows)) for i in range(3)
136
- ]
137
- palette = Palette(sys.stdout)
138
- for is_header, row in enumerate((header, *rows)):
139
- parts = []
140
- for i, cell in enumerate(row):
141
- plain = cell if i == len(row) - 1 else cell.ljust(widths[i])
142
- if palette.enabled and is_header == 0:
143
- parts.append(palette.paint(plain, bold=True))
144
- elif palette.enabled and i == 0:
145
- parts.append(palette.paint(plain, bold=True))
146
- elif palette.enabled and i == 1:
147
- fg = MAGENTA if cell == "orchestration" else GREEN
148
- parts.append(palette.paint(plain, fg=fg))
149
- else:
150
- parts.append(plain)
151
- print(" ".join(parts))
152
152
  return 0
153
153
 
154
154
 
155
+ def _parse_args(args: list[str], prefix: str = "--") -> tuple[list[str], list[str]]:
156
+ """Parse arguments into global flags (without --) and script args (with --)."""
157
+ global_flags = []
158
+ script_args = []
159
+ for arg in args:
160
+ if arg.startswith(prefix):
161
+ script_args.append(arg)
162
+ else:
163
+ global_flags.append(arg)
164
+ return global_flags, script_args
165
+
166
+
155
167
  def cmd_run(args: argparse.Namespace) -> int:
156
168
  """Run a script or orchestration from the vault."""
157
169
  vault = _load_vault(None)
158
- if vault.get(args.name) is None:
170
+ name = args.name
171
+ run_args = list(args.args or [])
172
+
173
+ # Check if this is a nested vault command
174
+ if name in vault._nested_vaults:
175
+ # Nested vault: need at least one more arg for script name
176
+ if not run_args:
177
+ available_includes = ", ".join(vault._nested_vaults.keys())
178
+ raise CLIError(
179
+ f"include {name!r} requires a script name.\n"
180
+ f"Use: sv run {name} <script-name>\n"
181
+ f"Available includes: {available_includes}"
182
+ )
183
+
184
+ script_name = run_args[0]
185
+ run_args = run_args[1:]
186
+
187
+ # Try to get from nested vault
188
+ target = vault.get_script_from_nested(name, script_name)
189
+ if target is None:
190
+ available = ", ".join(vault._nested_vaults[name].targets) or "none"
191
+ raise CLIError(
192
+ f"unknown target {script_name!r} in {name!r} "
193
+ f"(available: {available})", 127
194
+ )
195
+
196
+ # Parse global flags
197
+ global_flags, script_args = _parse_args(run_args, "--")
198
+ return run_target(vault, script_name, script_args, global_flags=global_flags)
199
+
200
+ # Root vault: single arg only
201
+ target = vault.get(name)
202
+ if target is None:
159
203
  available = ", ".join(vault.targets) or "none"
160
204
  raise CLIError(
161
- f"unknown target {args.name!r} (available: {available})", 127
205
+ f"unknown target {name!r} (available: {available})", 127
162
206
  )
163
- run_args = list(args.args or [])
164
- if run_args and run_args[0] == "--":
165
- run_args = run_args[1:]
207
+
208
+ # Parse global flags
209
+ global_flags, script_args = _parse_args(run_args, "--")
166
210
  try:
167
- return run_target(vault, args.name, run_args)
211
+ return run_target(vault, name, script_args, global_flags=global_flags)
168
212
  except OSError as exc:
169
213
  detail = exc.strerror or str(exc)
170
214
  raise CLIError(f"failed to run {args.name!r}: {detail}")
@@ -257,7 +301,7 @@ def _select_target(vault) -> str:
257
301
  if fzf and _interactive():
258
302
  try:
259
303
  proc = subprocess.run(
260
- [fzf],
304
+ [fzf, "--height", "40%"],
261
305
  input="\n".join(choices) + "\n",
262
306
  capture_output=True,
263
307
  text=True,
@@ -336,8 +380,79 @@ _COMPLETIONS = {
336
380
 
337
381
 
338
382
  def cmd_completion(args: argparse.Namespace) -> int:
339
- """Print a completion script for the given shell."""
340
- print(_COMPLETIONS[args.shell], end="")
383
+ """Print a completion script for the given shell.
384
+
385
+ Accepts a shell path (e.g., /usr/bin/bash) or shell name (bash, zsh, fish).
386
+ """
387
+ shell_path = args.shell
388
+ if not shell_path:
389
+ shell_path = shutil.which('bash') or shutil.which('zsh')
390
+
391
+ # Normalize shell path to basename if it's a full path
392
+ if shell_path.startswith('/'):
393
+ shell_name = os.path.basename(shell_path)
394
+ else:
395
+ shell_name = shell_path
396
+
397
+ # Try to find the shell by path if given
398
+ actual_shell = shutil.which(shell_path) or shutil.which(shell_name)
399
+ if actual_shell:
400
+ shell_name = os.path.basename(actual_shell)
401
+
402
+ if not shell_name or shell_name not in _COMPLETIONS:
403
+ print(f"Error: Shell '{shell_name}' not supported", file=sys.stderr)
404
+ return 1
405
+
406
+ print(_COMPLETIONS[shell_name], end="")
407
+ return 0
408
+
409
+
410
+ def cmd_activate(args: argparse.Namespace) -> int:
411
+ """Activate a specific vault or deactivate."""
412
+ if args.deactivate:
413
+ # Clear SV_ACTIVE_VAULT (print export for user to source)
414
+ print("export SV_ACTIVE_VAULT=\"\"", file=sys.stderr)
415
+ print("Deactivated. Use this command or pipe to your shell.", file=sys.stderr)
416
+ return 0
417
+
418
+ # Determine which vault to activate
419
+ if args.name is None:
420
+ # Activate current .sv directory (if we're in one)
421
+ current = Path.cwd()
422
+ # Check if current directory IS the .sv directory
423
+ hidden = hidden_dir_name()
424
+ if current.name == hidden and (current / "vault.toml").is_file():
425
+ # We're already in a .sv directory, use it
426
+ vault_name = current.parent.name
427
+ print(f"export SV_ACTIVE_VAULT=\"{vault_name}\"", file=sys.stderr)
428
+ print(f"Activated: {vault_name}", file=sys.stderr)
429
+ else:
430
+ print(f"Error: No vault found in {current}", file=sys.stderr)
431
+ return 1
432
+ else:
433
+ # Activate named vault
434
+ if args.name in RESERVED_NAMES:
435
+ print(f"Error: '{args.name}' is a reserved name", file=sys.stderr)
436
+ return 1
437
+
438
+ current = Path.cwd()
439
+ # Try: current/VAULT/.sv/vault.toml
440
+ vault_path = current / args.name / hidden_dir_name() / "vault.toml"
441
+ if not vault_path.is_file():
442
+ print(f"Error: Vault '{args.name}' not found", file=sys.stderr)
443
+ return 1
444
+
445
+ print(f"export SV_ACTIVE_VAULT=\"{args.name}\"", file=sys.stderr)
446
+ print(f"Activated: {args.name}", file=sys.stderr)
447
+
448
+ # Print the active vault info
449
+ try:
450
+ vault = _load_vault(None)
451
+ print(f"Active vault: {vault.name}", file=sys.stderr)
452
+ except Exception as e:
453
+ print(f"Error loading vault: {e}", file=sys.stderr)
454
+ return 1
455
+
341
456
  return 0
342
457
 
343
458
 
@@ -378,32 +493,47 @@ def build_parser() -> argparse.ArgumentParser:
378
493
  "list", help="list scripts and orchestrations in the vault"
379
494
  )
380
495
  lst.add_argument(
381
- "path",
382
- nargs="?",
383
- default=".",
496
+ "--path",
384
497
  metavar="PATH",
385
- help="directory to search for a vault from (default: current directory)",
498
+ default=None,
499
+ help="path to .sv directory (default: auto-detect root .sv in current or parent directories)",
500
+ )
501
+ lst.add_argument(
502
+ "--json", action="store_true", help="output as a JSON object with include info"
386
503
  )
387
504
  lst.add_argument(
388
- "--json", action="store_true", help="output as a JSON array"
505
+ "--nested", action="store_true",
506
+ help="show all nested vault scripts (default: only root scripts)"
389
507
  )
390
508
  lst.set_defaults(func=cmd_list)
391
509
 
392
- run = sub.add_parser("run", help="run a script or orchestration")
510
+ run = sub.add_parser("run", help="run a script or orchestration (prefix with include name for nested vaults, e.g., sv run c-hello build)")
393
511
  run.add_argument(
394
- "name", metavar="NAME", help="script or orchestration to run"
512
+ "--path",
513
+ metavar="PATH",
514
+ default=None,
515
+ help="path to .sv directory (default: auto-detect root .sv in current or parent directories)",
516
+ )
517
+ run.add_argument(
518
+ "name", metavar="NAME", help="script or orchestration to run (for nested vaults, prefix with include name)"
395
519
  )
396
520
  run.add_argument(
397
521
  "args",
398
522
  nargs=argparse.REMAINDER,
399
523
  metavar="ARG",
400
- help="arguments to pass to the script, optionally after --",
524
+ help="arguments to pass to the script (global flags without -- go to all scripts)",
401
525
  )
402
526
  run.set_defaults(func=cmd_run)
403
527
 
404
528
  add = sub.add_parser(
405
529
  "add", help="create a new file script in the vault"
406
530
  )
531
+ add.add_argument(
532
+ "--path",
533
+ metavar="PATH",
534
+ default=None,
535
+ help="path to .sv directory (default: auto-detect root .sv in current or parent directories)",
536
+ )
407
537
  add.add_argument(
408
538
  "name", metavar="NAME", help="name of the script to create"
409
539
  )
@@ -418,6 +548,12 @@ def build_parser() -> argparse.ArgumentParser:
418
548
  edit = sub.add_parser(
419
549
  "edit", help="edit a script, its env, or the vault configuration"
420
550
  )
551
+ edit.add_argument(
552
+ "--path",
553
+ metavar="PATH",
554
+ default=None,
555
+ help="path to .sv directory (default: auto-detect root .sv in current or parent directories)",
556
+ )
421
557
  edit.add_argument(
422
558
  "name",
423
559
  nargs="?",
@@ -433,15 +569,56 @@ def build_parser() -> argparse.ArgumentParser:
433
569
  edit.set_defaults(func=cmd_edit)
434
570
 
435
571
  completion = sub.add_parser(
436
- "completion", help="print a completion script for a shell"
572
+ "completion", help="print a completion script (use $shell for auto-detect from SHELL env)"
437
573
  )
438
574
  completion.add_argument(
439
575
  "shell",
440
- choices=sorted(_COMPLETIONS),
441
- help="shell to print completions for",
576
+ metavar="SHELL",
577
+ help="shell path/name (e.g., bash, zsh, fish, /usr/bin/bash, or $shell to auto-detect)",
442
578
  )
443
579
  completion.set_defaults(func=cmd_completion)
444
580
 
581
+ activate = sub.add_parser(
582
+ "activate", help="activate a specific vault (sets SV_ACTIVE_VAULT env var)"
583
+ )
584
+ activate.add_argument(
585
+ "name",
586
+ nargs="?",
587
+ default=None,
588
+ metavar="VAULT",
589
+ help="vault name to activate (default: use current .sv directory)",
590
+ )
591
+ activate.add_argument(
592
+ "--deactivate",
593
+ action="store_true",
594
+ help="deactivate any active vault (return to auto-detect)",
595
+ )
596
+ activate.set_defaults(func=cmd_activate)
597
+
598
+ deactivate = sub.add_parser(
599
+ "deactivate", help="deactivate any active vault (return to auto-detect)"
600
+ )
601
+ deactivate.add_argument(
602
+ "--path",
603
+ metavar="PATH",
604
+ default=None,
605
+ help="path to .sv directory (default: auto-detect root .sv in current or parent directories)",
606
+ )
607
+ deactivate.add_argument(
608
+ "--name",
609
+ nargs="?",
610
+ default=None,
611
+ metavar="VAULT",
612
+ help="vault name to activate (default: use current .sv directory)",
613
+ )
614
+ deactivate.add_argument(
615
+ "--deactivate",
616
+ action="store_true",
617
+ default=True,
618
+ help="deactivate any active vault (return to auto-detect)",
619
+ )
620
+ deactivate.set_defaults(func=cmd_activate)
621
+
445
622
  return parser
446
623
 
447
624
 
@@ -468,7 +645,21 @@ def main(argv: list[str] | None = None) -> int:
468
645
  argv = ["run", *argv]
469
646
  parser = build_parser()
470
647
  args = parser.parse_args(argv)
471
- return _run_command(args.func, args)
648
+ result = _run_command(args.func, args)
649
+ if (
650
+ sys.modules.get("pkg_resources")
651
+ and sys.modules.get("pkg_resources").get_provider()
652
+ and hasattr(sys.modules.get("pkg_resources").get_provider(), "_path")
653
+ ):
654
+ return result
655
+ # Check if this is a fresh installation (scriptvault not in pip list)
656
+ try:
657
+ import importlib.metadata as metadata
658
+ if "scriptvault" not in metadata.distributions():
659
+ print("Run 'sv completion bash | source' or 'sv completion zsh | source' or 'sv completion fish | source' to enable tab completion.")
660
+ except Exception:
661
+ pass
662
+ return result
472
663
 
473
664
 
474
665
  if __name__ == "__main__":