Shell completions for bash and zsh - #43
Conversation
|
Conflict against main now — a few other PRs touching |
New `skillscope completions <shell>` subcommand printing a bash or zsh script. Completes subcommands, flags, and the values of --sort and --theme. The script is GENERATED from the CLI's own lists rather than a hand-maintained copy: the parseArgs spec is lifted to a named OPTIONS const so the flag list is derived from what the parser actually accepts, commands come from COMMANDS, and --theme values come from the live themes registry. Adding a flag or a theme cannot leave completions silently stale. Dependency-free plain shell text, matching the project's zero-runtime-deps stance — no node subprocess at completion time. Word lists are single-quote escaped. README documents both the source <(...) form and permanent install. Closes notsointresting#34
e55a1f6 to
3989bd5
Compare
|
I saw the new Pace section in CONTRIBUTING — that's fair, and it's clearly about me. I opened eight PRs here in about an hour, which is exactly the "one person claiming everything within minutes" pattern you're describing, and I'm sorry for crowding the queue. I've rebased all seven of the open ones onto current Rather than unilaterally closing things, I'd rather you pick — happy to do any of these, just say which:
Either way I won't open anything new here until these are down to 1–2, and I'll stick to that going forward. For what it's worth, the ones most worth your time are probably #42 ( |
Adds a
completionssubcommand:skillscope completions bash/skillscope completions zshprints the script to stdout.It completes subcommands, flags, and the values of
--sortand--theme.Generated, not hand-maintained
The issue offers a static
scripts/completions.bashas one option. I went with generation instead, because a static script drifts silently the moment a flag or theme is added. So:parseArgsspec is lifted to a namedOPTIONSconst, and the flag list is derived from what the parser actually accepts;COMMANDS;--themevalues come from the livethemesregistry, so a new theme appears in--theme <TAB>with no extra work;--sortvalues come fromSORTS.That's the only structural change to
cli.ts— the options object moved out of theparseArgscall and is passed by name.Dependency-free
The output is plain shell text with no node subprocess at completion time, matching the project's zero-runtime-deps stance. Word lists are single-quote escaped so a value containing
'can't break out.Verified in a real shell
Beyond the unit tests, I sourced the generated script in bash and drove the function directly:
bash -nparses the emitted script cleanly.Tests
test/completions.test.ts: both shells list every command/flag/value, each registers with the correct hook (and#compdefis asserted to be the first line, or zsh won't autoload it), the output contains no node/require, and quote escaping holds.test/cli.test.ts: the subcommand prints for both shells, carries the real theme names, and rejects a missing or unsupported shell with exit 2.README gains a Shell completions section with the
source <(...)form and permanent install paths for both shells, including thefpath/compinitnote for zsh.Typecheck and the full suite (89 passing) are green.
Closes #34