@lexmanh/shed-cli 0.2.0-beta.6 → 0.2.0-beta.7

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 (2) hide show
  1. package/dist/cli.js +119 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -230,6 +230,122 @@ async function cleanCommand(path = ".", options = {}) {
230
230
  p.outro(outro6);
231
231
  }
232
232
 
233
+ // src/commands/completions.ts
234
+ var BASH = `# shed bash completion
235
+ _shed_completions() {
236
+ local cur prev cmds
237
+ COMPREPLY=()
238
+ cur="\${COMP_WORDS[COMP_CWORD]}"
239
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
240
+ cmds="scan clean undo doctor config completions"
241
+
242
+ case "\${prev}" in
243
+ scan)
244
+ COMPREPLY=( $(compgen -W "--json --max-age --all" -- "\${cur}") )
245
+ return 0
246
+ ;;
247
+ clean)
248
+ COMPREPLY=( $(compgen -W "--dry-run --execute --hard-delete --include-red --yes" -- "\${cur}") )
249
+ return 0
250
+ ;;
251
+ config)
252
+ COMPREPLY=( $(compgen -W "get set list reset" -- "\${cur}") )
253
+ return 0
254
+ ;;
255
+ completions)
256
+ COMPREPLY=( $(compgen -W "bash zsh fish" -- "\${cur}") )
257
+ return 0
258
+ ;;
259
+ esac
260
+
261
+ if [ "\${COMP_CWORD}" -eq 1 ]; then
262
+ COMPREPLY=( $(compgen -W "\${cmds} --version --help --verbose" -- "\${cur}") )
263
+ return 0
264
+ fi
265
+ }
266
+ complete -F _shed_completions shed
267
+ `;
268
+ var ZSH = `#compdef shed
269
+ # shed zsh completion
270
+
271
+ _shed() {
272
+ local -a commands
273
+ commands=(
274
+ 'scan:Scan for cleanable items without modifying anything'
275
+ 'clean:Interactive cleanup of detected items'
276
+ 'undo:List and restore items from previous cleanups'
277
+ 'doctor:Check environment and configuration'
278
+ 'config:Manage user preferences'
279
+ 'completions:Print shell completion script (bash | zsh | fish)'
280
+ )
281
+
282
+ if (( CURRENT == 2 )); then
283
+ _describe -t commands 'shed command' commands
284
+ return
285
+ fi
286
+
287
+ case "\${words[2]}" in
288
+ scan)
289
+ _arguments \\
290
+ '--json[Output machine-readable JSON]' \\
291
+ '--max-age[Only include items older than N days]:days' \\
292
+ '--all[Show every item (default: compact summary)]'
293
+ ;;
294
+ clean)
295
+ _arguments \\
296
+ '--dry-run[Preview operations without executing]' \\
297
+ '--execute[Actually perform the cleanup]' \\
298
+ '--hard-delete[Skip Trash, delete permanently]' \\
299
+ '--include-red[Include Red-tier (high-risk) items]' \\
300
+ '--yes[Skip interactive confirmations (CI mode)]'
301
+ ;;
302
+ config)
303
+ _values 'config action' get set list reset
304
+ ;;
305
+ completions)
306
+ _values 'shell' bash zsh fish
307
+ ;;
308
+ esac
309
+ }
310
+
311
+ _shed "$@"
312
+ `;
313
+ var FISH = `# shed fish completion
314
+ complete -c shed -f
315
+
316
+ # subcommands
317
+ complete -c shed -n '__fish_use_subcommand' -a 'scan' -d 'Scan for cleanable items'
318
+ complete -c shed -n '__fish_use_subcommand' -a 'clean' -d 'Interactive cleanup'
319
+ complete -c shed -n '__fish_use_subcommand' -a 'undo' -d 'Restore from previous cleanups'
320
+ complete -c shed -n '__fish_use_subcommand' -a 'doctor' -d 'Check environment'
321
+ complete -c shed -n '__fish_use_subcommand' -a 'config' -d 'Manage preferences'
322
+ complete -c shed -n '__fish_use_subcommand' -a 'completions' -d 'Print shell completion script'
323
+
324
+ # scan flags
325
+ complete -c shed -n '__fish_seen_subcommand_from scan' -l json -d 'Output JSON'
326
+ complete -c shed -n '__fish_seen_subcommand_from scan' -l max-age -d 'Min age in days'
327
+ complete -c shed -n '__fish_seen_subcommand_from scan' -l all -d 'Show every item'
328
+
329
+ # clean flags
330
+ complete -c shed -n '__fish_seen_subcommand_from clean' -l dry-run -d 'Preview only'
331
+ complete -c shed -n '__fish_seen_subcommand_from clean' -l execute -d 'Actually delete'
332
+ complete -c shed -n '__fish_seen_subcommand_from clean' -l hard-delete -d 'Skip Trash'
333
+ complete -c shed -n '__fish_seen_subcommand_from clean' -l include-red -d 'Include Red tier'
334
+ complete -c shed -n '__fish_seen_subcommand_from clean' -l yes -d 'Skip confirmations'
335
+
336
+ # config + completions argument values
337
+ complete -c shed -n '__fish_seen_subcommand_from config' -a 'get set list reset'
338
+ complete -c shed -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish'
339
+ `;
340
+ var SCRIPTS = { bash: BASH, zsh: ZSH, fish: FISH };
341
+ function completionsCommand(shell) {
342
+ if (shell !== "bash" && shell !== "zsh" && shell !== "fish") {
343
+ console.error("shed completions: shell must be one of: bash, zsh, fish");
344
+ process.exit(1);
345
+ }
346
+ process.stdout.write(SCRIPTS[shell]);
347
+ }
348
+
233
349
  // src/commands/config.ts
234
350
  import * as p2 from "@clack/prompts";
235
351
  import Conf from "conf";
@@ -746,11 +862,13 @@ program.command("clean [path]").description("Interactive cleanup of detected ite
746
862
  program.command("undo").description("List and restore items from previous cleanups").action(undoCommand);
747
863
  program.command("doctor").description("Check environment and configuration").action(doctorCommand);
748
864
  program.command("config").description("Manage user preferences").argument("[action]", "get | set | list | reset").argument("[key]", "Configuration key").argument("[value]", "Configuration value (for set)").action(configCommand);
865
+ program.command("completions").description("Print shell completion script").argument("<shell>", "bash | zsh | fish").action(completionsCommand);
749
866
  program.hook("preAction", (_thisCommand, actionCommand) => {
750
867
  const opts = program.opts();
751
868
  setVerbose(opts.verbose ?? false);
752
869
  const cmdOpts = actionCommand.opts();
753
- if (!cmdOpts.json) printLogo(version);
870
+ const isCompletions = actionCommand.name() === "completions";
871
+ if (!cmdOpts.json && !isCompletions) printLogo(version);
754
872
  });
755
873
  program.parseAsync(process.argv).catch((err) => {
756
874
  console.error("shed: fatal error:", err instanceof Error ? err.message : err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexmanh/shed-cli",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.7",
4
4
  "description": "Safe disk cleanup CLI for dev machines and Linux servers — git-aware, cross-stack, trash-by-default",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "conf": "^13.1.0",
24
24
  "execa": "^9.5.0",
25
25
  "picocolors": "^1.1.1",
26
- "@lexmanh/shed-core": "0.2.0-beta.6"
26
+ "@lexmanh/shed-core": "0.2.0-beta.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.10.0",