feat(setup): multi-shell integration with completions and custom names - #23
Merged
Conversation
…backend Extend the setup subcommand with --shell, --completions, --name, and --command flags backed by a ShellKind enum scoped to the three supported shells (zsh, bash, fish). Add a CompleteKind enum for the dynamic completion candidate kinds. The internal '__complete <kind>' backend is intercepted in main before clap parses, rather than being a hidden subcommand, because clap_complete emits hidden subcommands into the static completion script and would surface it as a visible candidate.
Add get_remote_branches to back the dynamic completion of remote branch names for workspace new. Returns remote/branch shorthands and skips symbolic refs like origin/HEAD.
Replace the single POSIX wrapper with shell-specific integration scripts for zsh, bash, and fish. Shell is auto-detected from $SHELL with --shell as an override. - zsh wrapper uses noglob so branch-name globs (feat/*, users/[id]) reach gx literally instead of being expanded by the shell - bash and fish wrappers handle workspace cd navigation natively - static command/flag completion is generated via clap_complete and layered with dynamic helpers for workspace names, branch names, remote branch names, and stash refs - --name/--command emit integration for a custom wrapper name and binary path, useful when developing gx locally alongside the installed release Human-facing output stays on stderr; stdout carries only the script (meant to be eval'd) and the __complete candidate list. Includes unit tests for shell detection, wrapper contents per shell, alias rendering, custom name substitution, completion wiring, and that the internal __complete helper never leaks into static completion output.
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
Polishes
gx setupso shell integration covers more shells, ships completion, supports custom wrapper names, and handles branch-name globs safely. Implements section 6 (Shell Integration Polish) of the workspace improvement plan.New CLI surface
Changes
$SHELL, with--shellas an override.noglob: the zsh wrapper aliases throughnoglobso branch-name arguments containing glob characters (gx workspace remove feat/*,gx checkout users/[id]) reachgxliterally instead of being expanded by the shell.clap_complete, then layered with dynamic helpers that provide live candidates for workspace names, branch names, remote branch names, and stash refs.--name/--commandemit integration for a custom wrapper name pointing at a specific binary, useful for developinggxlocally while keeping the installed release available asgx.__completebackend: a hiddengx __complete <kind>invocation backs the dynamic completion helpers. It is intercepted inmainbefore clap parses rather than being a clap subcommand, becauseclap_completeemits even hidden subcommands into the static completion script and would otherwise surface it as a visiblegx <TAB>candidate.get_remote_branchesfor remote-tracking branch completion (skips symbolic refs likeorigin/HEAD).Conventions honored
__completecandidate list; all human-facing notices go to stderr.Why
gx setuponly supported a single POSIX/zsh-style wrapper with no completion and no way to point at an alternate binary. This makes the integration usable across zsh, bash, and fish, adds completion that understands gx's own workspace/branch/stash state, and removes a class of breakage where the shell expanded branch-name globs before gx saw them.Testing
cargo buildpasses with no warnings.cargo testpasses (145 tests). 15 new unit tests cover shell detection, per-shell wrapper contents,noglobpresence in zsh, alias rendering and sorting, custom-name substitution, dynamic completion wiring for all four kinds across all three shells, and that the internal__completehelper never leaks into static completion output.