-
Notifications
You must be signed in to change notification settings - Fork 95
Add completion support for bash|zsh|fish #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you! Will take a look. |
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having some questions before I'll try it out. In general, I like the refactoring aspects of it (it is overdue)
RESPONSE="$($EXECUTABLE_PATH "${opts[@]}")" | ||
if [ $? -ne 0 -o -z "$RESPONSE" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have to check if all commands still work. But if it does it is a really nice refactoring
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. |
Now kubeswitch contains binary switcher, switch.sh script and switch.fish script. So to completely activate
My idea is to generate internals of switch.sh script by
I mean scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to implement several more completion points
|
||
return ns.SwitchNamespace(getKubeconfigPathFromFlag(), stateDirectory, noIndex) | ||
}, | ||
SilenceErrors: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to implement ValidArgs
function for autocompletion
reportNewContext(kc) | ||
return err | ||
}, | ||
SilenceUsage: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to implement ValidArgs function for autocompletion
return err | ||
} | ||
return delete_context.DeleteContext(ctxName) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to implement ValidArgs function for autocompletion
|
||
return alias.RemoveAlias(args[0], stateDirectory) | ||
}, | ||
SilenceErrors: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to implement ValidArgs function for autocompletion
@avlllo any chance you can continue this great work? 🙏 |
Completions were rewritten to make it possible to have completions for all shells.
cmd/switcher/switcher.go
was split into subcommandsswitch completion
was introduced incmd/switcher/completion.go
list-contexts
,delete-context
,unset-context
andcurrent-context
were implemented to make shell script as small as possible-u|-d|-c
were moved from shell into binaryNote: fish shell has built-in command
switch
sokubeswitch
was used for fishFixes #42, fixes #46