feat: interactive picker when cloak switch is run with no name#11
Open
thekvn wants to merge 1 commit into
Open
feat: interactive picker when cloak switch is run with no name#11thekvn wants to merge 1 commit into
cloak switch is run with no name#11thekvn wants to merge 1 commit into
Conversation
`cloak switch` (and `use`) previously errored without an argument. Now it lists available cloaks and lets you pick one, marking the current one. The picker renders to stderr (via inquirer's `output` option) so stdout stays clean for the `--print-env` eval used by the shell integration — selecting a cloak still produces only the `export CLAUDE_CONFIG_DIR=...` line on stdout. Aborting the picker (Ctrl-C / EOF) exits cleanly with empty stdout and no stack trace, so the shell `eval` is a harmless no-op. With no cloaks saved it exits 1 with a friendly hint. - src/commands/switch.js: picker path (injectable via options.pickChoice for tests) - src/cli.js: `switch <name>` -> `switch [name]` - src/lib/messages.js: switchPick prompt - tests: S-11 (pick switches), S-12 (no cloaks exits 1, empty stdout), S-13 (picking active = no stdout) - docs: README + CLAUDE.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
cloak switch(and itsusealias) used to error when called without an argument. Now it shows an interactive list of your cloaks and lets you pick one — the current cloak is marked(current).Why it's safe under shell integration
The shell wrapper runs
command cloak switch --print-env, capturing stdout foreval. So the picker UI is rendered to stderr (via inquirer'soutputoption); stdout still receives only theexport CLAUDE_CONFIG_DIR=...line. Verified manually that stdout stays clean while the menu shows on the terminal.Edge cases handled:
eval ""is a harmless no-op.1with a friendly "create one" hint.Changes
src/commands/switch.js— picker path (injectable viaoptions.pickChoice, matching the existingsetupChoicetest seam)src/cli.js—switch <name>→switch [name]src/lib/messages.js—switchPickpromptREADME.md,CLAUDE.mdTests
Added to
tests/switch.test.js(all existing cases still pass):1and writes nothing to stdoutFull suite green.
🤖 Generated with Claude Code