@tukuyomil032/broom 1.0.0

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +554 -0
  3. package/dist/commands/analyze.js +371 -0
  4. package/dist/commands/backup.js +257 -0
  5. package/dist/commands/clean.js +255 -0
  6. package/dist/commands/completion.js +714 -0
  7. package/dist/commands/config.js +474 -0
  8. package/dist/commands/doctor.js +280 -0
  9. package/dist/commands/duplicates.js +325 -0
  10. package/dist/commands/help.js +34 -0
  11. package/dist/commands/index.js +22 -0
  12. package/dist/commands/installer.js +266 -0
  13. package/dist/commands/optimize.js +270 -0
  14. package/dist/commands/purge.js +271 -0
  15. package/dist/commands/remove.js +184 -0
  16. package/dist/commands/reports.js +173 -0
  17. package/dist/commands/schedule.js +249 -0
  18. package/dist/commands/status.js +468 -0
  19. package/dist/commands/touchid.js +230 -0
  20. package/dist/commands/uninstall.js +336 -0
  21. package/dist/commands/update.js +182 -0
  22. package/dist/commands/watch.js +258 -0
  23. package/dist/index.js +131 -0
  24. package/dist/scanners/base.js +21 -0
  25. package/dist/scanners/browser-cache.js +111 -0
  26. package/dist/scanners/dev-cache.js +64 -0
  27. package/dist/scanners/docker.js +96 -0
  28. package/dist/scanners/downloads.js +66 -0
  29. package/dist/scanners/homebrew.js +82 -0
  30. package/dist/scanners/index.js +126 -0
  31. package/dist/scanners/installer.js +87 -0
  32. package/dist/scanners/ios-backups.js +82 -0
  33. package/dist/scanners/node-modules.js +75 -0
  34. package/dist/scanners/temp-files.js +65 -0
  35. package/dist/scanners/trash.js +90 -0
  36. package/dist/scanners/user-cache.js +62 -0
  37. package/dist/scanners/user-logs.js +53 -0
  38. package/dist/scanners/xcode.js +124 -0
  39. package/dist/types/index.js +23 -0
  40. package/dist/ui/index.js +5 -0
  41. package/dist/ui/monitors.js +345 -0
  42. package/dist/ui/output.js +304 -0
  43. package/dist/ui/prompts.js +270 -0
  44. package/dist/utils/config.js +133 -0
  45. package/dist/utils/debug.js +119 -0
  46. package/dist/utils/fs.js +283 -0
  47. package/dist/utils/help.js +265 -0
  48. package/dist/utils/index.js +6 -0
  49. package/dist/utils/paths.js +142 -0
  50. package/dist/utils/report.js +404 -0
  51. package/package.json +87 -0
@@ -0,0 +1,714 @@
1
+ /**
2
+ * completion command - Generate shell completion scripts
3
+ */
4
+ import { Command } from 'commander';
5
+ import chalk from 'chalk';
6
+ import { enhanceCommandHelp } from '../utils/help.js';
7
+ const BASH_COMPLETION = `# broom bash completion
8
+ _broom_completions() {
9
+ local cur prev opts commands
10
+ COMPREPLY=()
11
+ cur="\${COMP_WORDS[COMP_CWORD]}"
12
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
13
+
14
+ commands="clean analyze status optimize uninstall purge installer doctor backup restore duplicates schedule watch config touchid completion update remove help"
15
+
16
+ case "\${prev}" in
17
+ broom)
18
+ COMPREPLY=( $(compgen -W "\${commands}" -- \${cur}) )
19
+ return 0
20
+ ;;
21
+ clean)
22
+ COMPREPLY=( $(compgen -W "-n --dry-run -a --all -y --yes --unsafe -r --report -o --open --help" -- \${cur}) )
23
+ return 0
24
+ ;;
25
+ analyze)
26
+ COMPREPLY=( $(compgen -W "-p --path -d --depth -l --limit --help" -- \${cur}) )
27
+ return 0
28
+ ;;
29
+ status)
30
+ COMPREPLY=( $(compgen -W "-w --watch -i --interval --no-broom --help" -- \${cur}) )
31
+ return 0
32
+ ;;
33
+ optimize)
34
+ COMPREPLY=( $(compgen -W "-n --dry-run -y --yes -a --all --help" -- \${cur}) )
35
+ return 0
36
+ ;;
37
+ uninstall)
38
+ COMPREPLY=( $(compgen -W "-n --dry-run -y --yes --help" -- \${cur}) )
39
+ return 0
40
+ ;;
41
+ purge)
42
+ COMPREPLY=( $(compgen -W "-n --dry-run -y --yes --help" -- \${cur}) )
43
+ return 0
44
+ ;;
45
+ installer)
46
+ COMPREPLY=( $(compgen -W "-n --dry-run -y --yes --help" -- \${cur}) )
47
+ return 0
48
+ ;;
49
+ doctor)
50
+ COMPREPLY=( $(compgen -W "-v --verbose --help" -- \${cur}) )
51
+ return 0
52
+ ;;
53
+ backup)
54
+ COMPREPLY=( $(compgen -W "-l --list -c --clean -r --retention --help" -- \${cur}) )
55
+ return 0
56
+ ;;
57
+ restore)
58
+ COMPREPLY=( $(compgen -W "-l --list --help" -- \${cur}) )
59
+ return 0
60
+ ;;
61
+ duplicates)
62
+ COMPREPLY=( $(compgen -W "-p --path --min-size --hash -i --interactive -d --delete --help" -- \${cur}) )
63
+ return 0
64
+ ;;
65
+ schedule)
66
+ COMPREPLY=( $(compgen -W "-l --list -r --remove --daily --weekly --monthly --day --time --scanners --help" -- \${cur}) )
67
+ return 0
68
+ ;;
69
+ watch)
70
+ COMPREPLY=( $(compgen -W "-a --add -r --remove -l --list -c --check -p --path -t --threshold -n --notify --auto-clean --help" -- \${cur}) )
71
+ return 0
72
+ ;;
73
+ update)
74
+ COMPREPLY=( $(compgen -W "-c --check --help" -- \${cur}) )
75
+ return 0
76
+ ;;
77
+ remove)
78
+ COMPREPLY=( $(compgen -W "-y --yes -k --keep-config --help" -- \${cur}) )
79
+ return 0
80
+ ;;
81
+ touchid)
82
+ COMPREPLY=( $(compgen -W "enable disable status -y --yes --help" -- \${cur}) )
83
+ return 0
84
+ ;;
85
+ config)
86
+ COMPREPLY=( $(compgen -W "show set reset path --help" -- \${cur}) )
87
+ return 0
88
+ ;;
89
+ completion)
90
+ COMPREPLY=( $(compgen -W "install uninstall status bash zsh fish" -- \${cur}) )
91
+ return 0
92
+ ;;
93
+ *)
94
+ ;;
95
+ esac
96
+
97
+ COMPREPLY=( $(compgen -W "\${commands}" -- \${cur}) )
98
+ return 0
99
+ }
100
+ complete -F _broom_completions broom
101
+ `;
102
+ const ZSH_COMPLETION = `#compdef broom
103
+
104
+ _broom() {
105
+ local -a commands
106
+ local -a clean_opts uninstall_opts optimize_opts analyze_opts status_opts
107
+ local -a purge_opts installer_opts touchid_opts config_opts config_cmds touchid_cmds
108
+ local -a backup_opts restore_opts duplicates_opts schedule_opts watch_opts
109
+ local -a doctor_opts update_opts remove_opts completion_cmds
110
+
111
+ # Enable colored output
112
+ zstyle ':completion:*:descriptions' format '%B%F{blue}%d%f%b'
113
+ zstyle ':completion:*:messages' format '%F{yellow}%d%f'
114
+ zstyle ':completion:*:warnings' format '%F{red}No matches found%f'
115
+ zstyle ':completion:*' group-name ''
116
+ zstyle ':completion:*:*:broom:*' list-colors '=(#b)(*)-- *=34=36'
117
+
118
+ commands=(
119
+ 'clean:🧹 Deep system cleanup with category selection'
120
+ 'analyze:📊 Analyze disk space usage with visual graphs'
121
+ 'status:💻 Real-time system monitoring dashboard'
122
+ 'optimize:⚡ System maintenance and optimization'
123
+ 'uninstall:🗑️ Remove apps and their leftovers'
124
+ 'purge:🔥 Clean project-specific build artifacts'
125
+ 'installer:📦 Find and remove installer files'
126
+ 'doctor:🩺 Run system health diagnostics'
127
+ 'backup:💾 Manage file backups before cleanup'
128
+ 'restore:♻️ Restore files from backup'
129
+ 'duplicates:🔍 Find and remove duplicate files'
130
+ 'schedule:⏰ Schedule automated cleanups'
131
+ 'watch:👁️ Monitor directory sizes'
132
+ 'reports:📊 Manage cleanup reports'
133
+ 'config:⚙️ Manage broom configuration'
134
+ 'touchid:👆 Configure Touch ID for sudo'
135
+ 'completion:📝 Install shell completion'
136
+ 'update:⬆️ Update broom to latest version'
137
+ 'remove:❌ Uninstall broom from system'
138
+ 'help:❓ Display help for command'
139
+ )
140
+
141
+ clean_opts=(
142
+ '(-n --dry-run)'{-n,--dry-run}'[Preview only, no deletions]'
143
+ '(-a --all)'{-a,--all}'[Clean all categories without prompting]'
144
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
145
+ '--unsafe[Include risky categories in cleanup]'
146
+ '(-r --report)'{-r,--report}'[Generate HTML report after cleanup]'
147
+ '(-o --open)'{-o,--open}'[Open report in browser after generation]'
148
+ '(-h --help)'{-h,--help}'[Display help]'
149
+ )
150
+
151
+ analyze_opts=(
152
+ '(-p --path)'{-p,--path}'[Path to analyze]:path:_files -/'
153
+ '(-d --depth)'{-d,--depth}'[Scan depth]:depth:(1 2 3 4 5)'
154
+ '(-l --limit)'{-l,--limit}'[Max items to show]:limit:(10 15 20 30 50)'
155
+ '(-h --help)'{-h,--help}'[Display help]'
156
+ )
157
+
158
+ status_opts=(
159
+ '(-w --watch)'{-w,--watch}'[Live monitoring mode]'
160
+ '(-i --interval)'{-i,--interval}'[Update interval in seconds]:seconds:(1 2 5 10)'
161
+ '--no-broom[Disable broom animation]'
162
+ '(-h --help)'{-h,--help}'[Display help]'
163
+ )
164
+
165
+ uninstall_opts=(
166
+ '(-n --dry-run)'{-n,--dry-run}'[Preview only, no deletions]'
167
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
168
+ '(-h --help)'{-h,--help}'[Display help]'
169
+ )
170
+
171
+ optimize_opts=(
172
+ '(-n --dry-run)'{-n,--dry-run}'[Preview only, no changes]'
173
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
174
+ '(-a --all)'{-a,--all}'[Run all optimization tasks]'
175
+ '(-h --help)'{-h,--help}'[Display help]'
176
+ )
177
+
178
+ doctor_opts=(
179
+ '(-v --verbose)'{-v,--verbose}'[Show detailed information]'
180
+ '(-h --help)'{-h,--help}'[Display help]'
181
+ )
182
+
183
+ backup_opts=(
184
+ '(-l --list)'{-l,--list}'[List all backups]'
185
+ '(-c --clean)'{-c,--clean}'[Remove expired backups]'
186
+ '(-r --retention)'{-r,--retention}'[Set retention period in days]:days:(7 14 30 60 90)'
187
+ '(-h --help)'{-h,--help}'[Display help]'
188
+ )
189
+
190
+ restore_opts=(
191
+ '(-l --list)'{-l,--list}'[List restorable backups]'
192
+ '(-h --help)'{-h,--help}'[Display help]'
193
+ )
194
+
195
+ duplicates_opts=(
196
+ '(-p --path)'{-p,--path}'[Path to scan]:path:_files -/'
197
+ '--min-size[Minimum file size]:size:(1MB 5MB 10MB 50MB 100MB)'
198
+ '--hash[Hash algorithm]:algorithm:(md5 sha256)'
199
+ '(-i --interactive)'{-i,--interactive}'[Interactive mode]'
200
+ '(-d --delete)'{-d,--delete}'[Automatically delete duplicates]'
201
+ '(-h --help)'{-h,--help}'[Display help]'
202
+ )
203
+
204
+ schedule_opts=(
205
+ '(-l --list)'{-l,--list}'[Show current schedule]'
206
+ '(-r --remove)'{-r,--remove}'[Remove scheduled cleanup]'
207
+ '--daily[Schedule daily cleanup]'
208
+ '--weekly[Schedule weekly cleanup]'
209
+ '--monthly[Schedule monthly cleanup]'
210
+ '--day[Day of week for weekly]:day:(monday tuesday wednesday thursday friday saturday sunday)'
211
+ '--time[Time to run]:time:'
212
+ '--scanners[Comma-separated list of scanners]:scanners:'
213
+ '(-h --help)'{-h,--help}'[Display help]'
214
+ )
215
+
216
+ watch_opts=(
217
+ '(-a --add)'{-a,--add}'[Add a new watch]'
218
+ '(-r --remove)'{-r,--remove}'[Remove a watch]:path:_files -/'
219
+ '(-l --list)'{-l,--list}'[List all watches]'
220
+ '(-c --check)'{-c,--check}'[Check all watches now]'
221
+ '(-p --path)'{-p,--path}'[Path to watch]:path:_files -/'
222
+ '(-t --threshold)'{-t,--threshold}'[Size threshold]:size:(1GB 5GB 10GB 50GB 100GB)'
223
+ '(-n --notify)'{-n,--notify}'[Enable notifications]'
224
+ '--auto-clean[Automatically clean when threshold exceeded]'
225
+ '(-h --help)'{-h,--help}'[Display help]'
226
+ )
227
+
228
+ update_opts=(
229
+ '(-c --check)'{-c,--check}'[Check for updates only]'
230
+ '(-h --help)'{-h,--help}'[Display help]'
231
+ )
232
+
233
+ remove_opts=(
234
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
235
+ '(-k --keep-config)'{-k,--keep-config}'[Keep configuration files]'
236
+ '(-h --help)'{-h,--help}'[Display help]'
237
+ )
238
+
239
+ purge_opts=(
240
+ '(-n --dry-run)'{-n,--dry-run}'[Preview only, no deletions]'
241
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
242
+ '(-h --help)'{-h,--help}'[Display help]'
243
+ )
244
+
245
+ installer_opts=(
246
+ '(-n --dry-run)'{-n,--dry-run}'[Preview only, no deletions]'
247
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
248
+ '(-h --help)'{-h,--help}'[Display help]'
249
+ )
250
+
251
+ touchid_cmds=(
252
+ 'enable:Enable Touch ID for sudo'
253
+ 'disable:Disable Touch ID for sudo'
254
+ 'status:Show Touch ID sudo status'
255
+ )
256
+
257
+ touchid_opts=(
258
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
259
+ '(-h --help)'{-h,--help}'[Display help]'
260
+ )
261
+
262
+ config_cmds=(
263
+ 'show:Show current configuration'
264
+ 'set:Set a configuration value'
265
+ 'reset:Reset configuration to defaults'
266
+ 'path:Show configuration file path'
267
+ )
268
+
269
+ config_opts=(
270
+ '(-h --help)'{-h,--help}'[Display help]'
271
+ )
272
+
273
+ completion_cmds=(
274
+ 'install:Install completion for your shell (automatic)'
275
+ 'uninstall:Remove completion'
276
+ 'status:Check if completion is installed'
277
+ 'bash:Print bash completion script'
278
+ 'zsh:Print zsh completion script'
279
+ 'fish:Print fish completion script'
280
+ )
281
+
282
+ touchid_opts=(
283
+ '(-y --yes)'{-y,--yes}'[Skip confirmation prompts]'
284
+ '(-h --help)'{-h,--help}'[Display help]'
285
+ )
286
+
287
+ config_cmds=(
288
+ 'show:Show current configuration'
289
+ 'set:Set a configuration value'
290
+ 'reset:Reset configuration to defaults'
291
+ 'path:Show configuration file path'
292
+ )
293
+
294
+ config_opts=(
295
+ '(-h --help)'{-h,--help}'[Display help]'
296
+ )
297
+
298
+ _arguments -C \\
299
+ '(-v --version)'{-v,--version}'[Output the current version]' \\
300
+ '(-h --help)'{-h,--help}'[Display help for command]' \\
301
+ '1: :->command' \\
302
+ '*:: :->args'
303
+
304
+ case $state in
305
+ command)
306
+ _describe -t commands 'broom command' commands
307
+ ;;
308
+ args)
309
+ case $words[1] in
310
+ clean)
311
+ _arguments $clean_opts
312
+ ;;
313
+ uninstall)
314
+ _arguments $uninstall_opts
315
+ ;;
316
+ optimize)
317
+ _arguments $optimize_opts
318
+ ;;
319
+ analyze)
320
+ _arguments $analyze_opts
321
+ ;;
322
+ status)
323
+ _arguments $status_opts
324
+ ;;
325
+ purge)
326
+ _arguments $purge_opts
327
+ ;;
328
+ installer)
329
+ _arguments $installer_opts
330
+ ;;
331
+ touchid)
332
+ _arguments -C $touchid_opts \\
333
+ '1: :->touchid_cmd' \\
334
+ '*:: :->touchid_args'
335
+ case $state in
336
+ touchid_cmd)
337
+ _describe -t touchid_cmds 'touchid command' touchid_cmds
338
+ ;;
339
+ esac
340
+ ;;
341
+ config)
342
+ _arguments -C $config_opts \
343
+ '1: :->config_cmd' \
344
+ '*:: :->config_args'
345
+ case $state in
346
+ config_cmd)
347
+ _describe -t config_cmds 'config command' config_cmds
348
+ ;;
349
+ esac
350
+ ;;
351
+ completion)
352
+ _arguments -C \
353
+ '1: :->completion_cmd' \
354
+ '*:: :->completion_args'
355
+ case $state in
356
+ completion_cmd)
357
+ _describe -t completion_cmds 'completion command' completion_cmds
358
+ ;;
359
+ esac
360
+ ;;
361
+ doctor)
362
+ _arguments $doctor_opts
363
+ ;;
364
+ backup)
365
+ _arguments $backup_opts
366
+ ;;
367
+ restore)
368
+ _arguments $restore_opts '*:backup-id:'
369
+ ;;
370
+ duplicates)
371
+ _arguments $duplicates_opts
372
+ ;;
373
+ schedule)
374
+ _arguments $schedule_opts
375
+ ;;
376
+ watch)
377
+ _arguments $watch_opts
378
+ ;;
379
+ update)
380
+ _arguments $update_opts
381
+ ;;
382
+ remove)
383
+ _arguments $remove_opts
384
+ ;;
385
+ esac
386
+ ;;
387
+ esac
388
+ }
389
+
390
+ _broom "$@"
391
+ `;
392
+ const FISH_COMPLETION = `# broom fish completion
393
+
394
+ # Disable file completion for broom
395
+ complete -c broom -f
396
+
397
+ # Main commands
398
+ complete -c broom -n __fish_use_subcommand -a clean -d '🧹 Scan and clean up disk space'
399
+ complete -c broom -n __fish_use_subcommand -a analyze -d '📊 Analyze disk space usage'
400
+ complete -c broom -n __fish_use_subcommand -a status -d '💻 Show system status and resource usage'
401
+ complete -c broom -n __fish_use_subcommand -a optimize -d '⚡ System maintenance and optimization'
402
+ complete -c broom -n __fish_use_subcommand -a uninstall -d '🗑️ Remove apps and their leftovers'
403
+ complete -c broom -n __fish_use_subcommand -a purge -d '🔥 Clean project-specific build artifacts'
404
+ complete -c broom -n __fish_use_subcommand -a installer -d '📦 Find and remove installer files'
405
+ complete -c broom -n __fish_use_subcommand -a doctor -d '🩺 Run system health diagnostics'
406
+ complete -c broom -n __fish_use_subcommand -a backup -d '💾 Manage file backups'
407
+ complete -c broom -n __fish_use_subcommand -a restore -d '♻️ Restore files from backup'
408
+ complete -c broom -n __fish_use_subcommand -a duplicates -d '🔍 Find and remove duplicate files'
409
+ complete -c broom -n __fish_use_subcommand -a schedule -d '⏰ Schedule automated cleanups'
410
+ complete -c broom -n __fish_use_subcommand -a watch -d '👁️ Monitor directory sizes'
411
+ complete -c broom -n __fish_use_subcommand -a reports -d '📊 Manage cleanup reports'
412
+ complete -c broom -n __fish_use_subcommand -a touchid -d '👆 Configure Touch ID for sudo'
413
+ complete -c broom -n __fish_use_subcommand -a completion -d '📝 Install shell completion'
414
+ complete -c broom -n __fish_use_subcommand -a config -d '⚙️ Manage broom configuration'
415
+ complete -c broom -n __fish_use_subcommand -a update -d '⬆️ Update broom'
416
+ complete -c broom -n __fish_use_subcommand -a remove -d '❌ Uninstall broom'
417
+ complete -c broom -n __fish_use_subcommand -a help -d '❓ Display help for command'
418
+
419
+ # Global options
420
+ complete -c broom -s v -l version -d 'Output the current version'
421
+ complete -c broom -s h -l help -d 'Display help for command'
422
+
423
+ # clean options
424
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s n -l dry-run -d '🔍 Preview only'
425
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s a -l all -d '🌟 Clean all categories'
426
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s y -l yes -d '✓ Skip confirmation'
427
+ complete -c broom -n '__fish_seen_subcommand_from clean' -l unsafe -d '⚠️ Include risky categories'
428
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s r -l report -d '📊 Generate HTML report'
429
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s o -l open -d '🌐 Open report in browser'
430
+ complete -c broom -n '__fish_seen_subcommand_from clean' -s h -l help -d '❓ Display help'
431
+
432
+ # uninstall options
433
+ complete -c broom -n '__fish_seen_subcommand_from uninstall' -s n -l dry-run -d '🔍 Preview only'
434
+ complete -c broom -n '__fish_seen_subcommand_from uninstall' -s y -l yes -d '✓ Skip confirmation'
435
+ complete -c broom -n '__fish_seen_subcommand_from uninstall' -s h -l help -d '❓ Display help'
436
+
437
+ # optimize options
438
+ complete -c broom -n '__fish_seen_subcommand_from optimize' -s n -l dry-run -d '🔍 Preview only'
439
+ complete -c broom -n '__fish_seen_subcommand_from optimize' -s y -l yes -d '✓ Skip confirmation'
440
+ complete -c broom -n '__fish_seen_subcommand_from optimize' -s a -l all -d '🌟 Run all tasks'
441
+ complete -c broom -n '__fish_seen_subcommand_from optimize' -s h -l help -d '❓ Display help'
442
+
443
+ # status options
444
+ complete -c broom -n '__fish_seen_subcommand_from status' -s w -l watch -d 'Live monitoring mode'
445
+ complete -c broom -n '__fish_seen_subcommand_from status' -s i -l interval -d 'Update interval'
446
+ complete -c broom -n '__fish_seen_subcommand_from status' -s h -l help -d 'Display help'
447
+
448
+ # purge options
449
+ complete -c broom -n '__fish_seen_subcommand_from purge' -s n -l dry-run -d 'Preview only'
450
+ complete -c broom -n '__fish_seen_subcommand_from purge' -s y -l yes -d 'Skip confirmation'
451
+ complete -c broom -n '__fish_seen_subcommand_from purge' -s h -l help -d 'Display help'
452
+
453
+ # installer options
454
+ complete -c broom -n '__fish_seen_subcommand_from installer' -s n -l dry-run -d 'Preview only'
455
+ complete -c broom -n '__fish_seen_subcommand_from installer' -s y -l yes -d 'Skip confirmation'
456
+ complete -c broom -n '__fish_seen_subcommand_from installer' -s h -l help -d 'Display help'
457
+
458
+ # touchid subcommands
459
+ complete -c broom -n '__fish_seen_subcommand_from touchid' -a enable -d 'Enable Touch ID for sudo'
460
+ complete -c broom -n '__fish_seen_subcommand_from touchid' -a disable -d 'Disable Touch ID for sudo'
461
+ complete -c broom -n '__fish_seen_subcommand_from touchid' -a status -d 'Show Touch ID sudo status'
462
+ complete -c broom -n '__fish_seen_subcommand_from touchid' -s y -l yes -d 'Skip confirmation'
463
+ complete -c broom -n '__fish_seen_subcommand_from touchid' -s h -l help -d 'Display help'
464
+
465
+ # config subcommands
466
+ complete -c broom -n '__fish_seen_subcommand_from config' -a show -d 'Show current configuration'
467
+ complete -c broom -n '__fish_seen_subcommand_from config' -a set -d 'Set a configuration value'
468
+ complete -c broom -n '__fish_seen_subcommand_from config' -a reset -d 'Reset configuration'
469
+ complete -c broom -n '__fish_seen_subcommand_from config' -a path -d 'Show config file path'
470
+ complete -c broom -n '__fish_seen_subcommand_from config' -s h -l help -d 'Display help'
471
+
472
+ # completion subcommands
473
+ complete -c broom -n '__fish_seen_subcommand_from completion' -a bash -d 'Generate bash completion'
474
+ complete -c broom -n '__fish_seen_subcommand_from completion' -a zsh -d 'Generate zsh completion'
475
+ complete -c broom -n '__fish_seen_subcommand_from completion' -a fish -d 'Generate fish completion'
476
+
477
+ # reports subcommands
478
+ complete -c broom -n '__fish_seen_subcommand_from reports' -a list -d 'List all reports'
479
+ complete -c broom -n '__fish_seen_subcommand_from reports' -a clean -d 'Delete all reports'
480
+ complete -c broom -n '__fish_seen_subcommand_from reports' -a open -d 'Open latest report'
481
+ complete -c broom -n '__fish_seen_subcommand_from reports' -s y -l yes -d 'Skip confirmation'
482
+ complete -c broom -n '__fish_seen_subcommand_from reports' -s h -l help -d 'Display help'
483
+ `;
484
+ /**
485
+ * Print completion script for a shell
486
+ */
487
+ function printCompletion(shell) {
488
+ switch (shell) {
489
+ case 'bash':
490
+ console.log(BASH_COMPLETION);
491
+ console.error(chalk.dim('\n# Add this to your ~/.bashrc or ~/.bash_profile:'));
492
+ console.error(chalk.dim('# eval "$(broom completion bash)"'));
493
+ break;
494
+ case 'zsh':
495
+ console.log(ZSH_COMPLETION);
496
+ console.error(chalk.dim('\n# Save to a file in your fpath, e.g.:'));
497
+ console.error(chalk.dim('# broom completion zsh > ~/.zsh/completions/_broom'));
498
+ console.error(chalk.dim('# Then add ~/.zsh/completions to your fpath in ~/.zshrc'));
499
+ break;
500
+ case 'fish':
501
+ console.log(FISH_COMPLETION);
502
+ console.error(chalk.dim('\n# Save to your fish completions directory:'));
503
+ console.error(chalk.dim('# broom completion fish > ~/.config/fish/completions/broom.fish'));
504
+ break;
505
+ default:
506
+ console.error(chalk.red(`Unknown shell: ${shell}`));
507
+ console.log('Supported shells: bash, zsh, fish');
508
+ }
509
+ }
510
+ /**
511
+ * Detect current shell
512
+ */
513
+ function detectShell() {
514
+ return process.env.SHELL?.split('/').pop() || 'zsh';
515
+ }
516
+ /**
517
+ * Install completion automatically
518
+ */
519
+ async function installCompletion() {
520
+ const { writeFile, mkdir, access, readFile, appendFile } = await import('fs/promises');
521
+ const { homedir } = await import('os');
522
+ const shell = detectShell();
523
+ console.log(chalk.cyan(`\n🔧 Installing ${shell} completion...\n`));
524
+ try {
525
+ if (shell === 'zsh') {
526
+ const completionDir = `${homedir()}/.zsh/completions`;
527
+ const completionFile = `${completionDir}/_broom`;
528
+ const zshrc = `${homedir()}/.zshrc`;
529
+ // Create completion directory
530
+ await mkdir(completionDir, { recursive: true });
531
+ // Write completion file
532
+ await writeFile(completionFile, ZSH_COMPLETION, 'utf-8');
533
+ console.log(chalk.green('✓ Completion file created'));
534
+ // Check if fpath is already configured
535
+ let zshrcContent = '';
536
+ try {
537
+ zshrcContent = await readFile(zshrc, 'utf-8');
538
+ }
539
+ catch {
540
+ // .zshrc doesn't exist yet
541
+ }
542
+ if (!zshrcContent.includes('~/.zsh/completions')) {
543
+ await appendFile(zshrc, '\n# Broom completion\nfpath=(~/.zsh/completions $fpath)\nautoload -Uz compinit && compinit\n', 'utf-8');
544
+ console.log(chalk.green('✓ Added to ~/.zshrc'));
545
+ }
546
+ console.log(chalk.green('\n✅ Installation complete!'));
547
+ console.log(chalk.dim('\nRun the following to activate:'));
548
+ console.log(chalk.yellow(' source ~/.zshrc\n'));
549
+ console.log(chalk.dim('Or restart your terminal.\n'));
550
+ }
551
+ else if (shell === 'bash') {
552
+ const completionDir = `${homedir()}/.bash_completion.d`;
553
+ const completionFile = `${completionDir}/broom`;
554
+ const bashrc = `${homedir()}/.bashrc`;
555
+ await mkdir(completionDir, { recursive: true });
556
+ await writeFile(completionFile, BASH_COMPLETION, 'utf-8');
557
+ console.log(chalk.green('✓ Completion file created'));
558
+ let bashrcContent = '';
559
+ try {
560
+ bashrcContent = await readFile(bashrc, 'utf-8');
561
+ }
562
+ catch {
563
+ // .bashrc doesn't exist
564
+ }
565
+ if (!bashrcContent.includes('.bash_completion.d/broom')) {
566
+ await appendFile(bashrc, '\n# Broom completion\nsource ~/.bash_completion.d/broom\n', 'utf-8');
567
+ console.log(chalk.green('✓ Added to ~/.bashrc'));
568
+ }
569
+ console.log(chalk.green('\n✅ Installation complete!'));
570
+ console.log(chalk.dim('\nRun the following to activate:'));
571
+ console.log(chalk.yellow(' source ~/.bashrc\n'));
572
+ }
573
+ else if (shell === 'fish') {
574
+ const completionDir = `${homedir()}/.config/fish/completions`;
575
+ const completionFile = `${completionDir}/broom.fish`;
576
+ await mkdir(completionDir, { recursive: true });
577
+ await writeFile(completionFile, FISH_COMPLETION, 'utf-8');
578
+ console.log(chalk.green('\n✅ Installation complete!'));
579
+ console.log(chalk.dim('\nFish automatically loads completions.\n'));
580
+ console.log(chalk.dim('Restart your terminal or run: exec fish\n'));
581
+ }
582
+ else {
583
+ console.log(chalk.red(`\n❌ Unsupported shell: ${shell}`));
584
+ console.log(chalk.dim('Supported: bash, zsh, fish\n'));
585
+ }
586
+ }
587
+ catch (error) {
588
+ console.log(chalk.red(`\n❌ Installation failed: ${error}\n`));
589
+ }
590
+ }
591
+ /**
592
+ * Uninstall completion
593
+ */
594
+ async function uninstallCompletion() {
595
+ const { unlink } = await import('fs/promises');
596
+ const { homedir } = await import('os');
597
+ const shell = detectShell();
598
+ console.log(chalk.cyan(`\n🗑️ Uninstalling ${shell} completion...\n`));
599
+ try {
600
+ if (shell === 'zsh') {
601
+ const completionFile = `${homedir()}/.zsh/completions/_broom`;
602
+ await unlink(completionFile);
603
+ console.log(chalk.green('✅ Completion removed'));
604
+ console.log(chalk.dim('\nNote: You may want to manually remove the fpath config from ~/.zshrc\n'));
605
+ }
606
+ else if (shell === 'bash') {
607
+ const completionFile = `${homedir()}/.bash_completion.d/broom`;
608
+ await unlink(completionFile);
609
+ console.log(chalk.green('✅ Completion removed'));
610
+ console.log(chalk.dim('\nNote: You may want to manually remove the source line from ~/.bashrc\n'));
611
+ }
612
+ else if (shell === 'fish') {
613
+ const completionFile = `${homedir()}/.config/fish/completions/broom.fish`;
614
+ await unlink(completionFile);
615
+ console.log(chalk.green('✅ Completion removed\n'));
616
+ }
617
+ }
618
+ catch {
619
+ console.log(chalk.yellow('⚠️ Completion file not found or already removed\n'));
620
+ }
621
+ }
622
+ /**
623
+ * Check completion status
624
+ */
625
+ async function checkStatus() {
626
+ const { access } = await import('fs/promises');
627
+ const { homedir } = await import('os');
628
+ const shell = detectShell();
629
+ console.log(chalk.cyan('\n📊 Completion Status\n'));
630
+ console.log(`Current shell: ${chalk.yellow(shell)}`);
631
+ let installed = false;
632
+ let location = '';
633
+ try {
634
+ if (shell === 'zsh') {
635
+ location = `${homedir()}/.zsh/completions/_broom`;
636
+ await access(location);
637
+ installed = true;
638
+ }
639
+ else if (shell === 'bash') {
640
+ location = `${homedir()}/.bash_completion.d/broom`;
641
+ await access(location);
642
+ installed = true;
643
+ }
644
+ else if (shell === 'fish') {
645
+ location = `${homedir()}/.config/fish/completions/broom.fish`;
646
+ await access(location);
647
+ installed = true;
648
+ }
649
+ if (installed) {
650
+ console.log(chalk.green('✓ Completion is installed'));
651
+ console.log(chalk.dim(` ${location}\n`));
652
+ }
653
+ }
654
+ catch {
655
+ console.log(chalk.yellow('✗ Completion is not installed'));
656
+ console.log(chalk.dim('\nRun to install:'));
657
+ console.log(chalk.yellow(' broom completion install\n'));
658
+ }
659
+ }
660
+ /**
661
+ * Show completion help
662
+ */
663
+ function showCompletionHelp() {
664
+ console.log(chalk.bold('\n📝 Shell Completion\n'));
665
+ console.log('Enable tab completion for broom commands and options.\n');
666
+ console.log(chalk.bold('Usage:'));
667
+ console.log(' broom completion [command]\n');
668
+ console.log(chalk.bold('Commands:'));
669
+ console.log(' install Install completion for your shell (automatic)');
670
+ console.log(' uninstall Remove completion');
671
+ console.log(' status Check if completion is installed');
672
+ console.log(' bash/zsh/fish Print completion script for manual setup\n');
673
+ console.log(chalk.bold('Examples:'));
674
+ console.log(chalk.dim(' # Automatic installation (recommended)'));
675
+ console.log(chalk.yellow(' broom completion install\n'));
676
+ console.log(chalk.dim(' # Check status'));
677
+ console.log(chalk.yellow(' broom completion status\n'));
678
+ console.log(chalk.dim(' # Manual installation (advanced)'));
679
+ console.log(chalk.dim(' broom completion zsh > ~/.zsh/completions/_broom\n'));
680
+ }
681
+ /**
682
+ * Create completion command
683
+ */
684
+ export function createCompletionCommand() {
685
+ const cmd = new Command('completion')
686
+ .description('Install shell completion for tab completion')
687
+ .argument('[action]', 'Action: install, uninstall, status, or shell type (bash/zsh/fish)')
688
+ .action(async (action) => {
689
+ if (!action) {
690
+ showCompletionHelp();
691
+ return;
692
+ }
693
+ switch (action) {
694
+ case 'install':
695
+ await installCompletion();
696
+ break;
697
+ case 'uninstall':
698
+ await uninstallCompletion();
699
+ break;
700
+ case 'status':
701
+ await checkStatus();
702
+ break;
703
+ case 'bash':
704
+ case 'zsh':
705
+ case 'fish':
706
+ printCompletion(action);
707
+ break;
708
+ default:
709
+ console.log(chalk.red(`\n❌ Unknown action: ${action}\n`));
710
+ showCompletionHelp();
711
+ }
712
+ });
713
+ return enhanceCommandHelp(cmd);
714
+ }