kubeswitch
kubeswitch copied to clipboard
Add completion support for bash|zsh|fish
Completions were rewritten to make it possible to have completions for all shells.
-
cmd/switcher/switcher.go
was split into subcommands - new subcommand
switch completion
was introduced incmd/switcher/completion.go
- new subcommands
list-contexts
,delete-context
,unset-context
andcurrent-context
were implemented to make shell script as small as possible - flags
-u|-d|-c
were moved from shell into binary
Note: fish shell has built-in command switch
so kubeswitch
was used for fish
Fixes #42, fixes #46
Thank you! Will take a look. Could you also resolve the merge conflicts?
Could you also resolve the merge conflicts?
Fixed
@danielfoehrKn What do you think about embedding? There will be only one binary which would produce needed shell functions to source them. Final flow be like:
source <(switcher init bash —enable-completion) # here switcher init outputs function switch() from hack/switch/switch.sh with required completions
switch …
What do you think about embedding?
I am not quite sure how that is different from your current approach . You could still use the switcher binary to generate the bash|fish|zsh completions and source them. Maybe I am misunderstanding something.
I am not quite sure how that is different from your current approach
Now kubeswitch contains binary switcher, switch.sh script and switch.fish script. So to completely activate switch
with full completions support users should execute
source switch.sh
source <(switch completion bash)
My idea is to generate internals of switch.sh script by init
subcommand. So the script above would be
source <(switcher init bash)
I mean scripts switch.sh
and switch.fish
can be also embedded into binary. Final distribution would contain only one binary without additional scripts