-
Notifications
You must be signed in to change notification settings - Fork 312
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
Support bash and zsh completion #606
Conversation
8d71e20
to
a5de6e3
Compare
Codecov Report
@@ Coverage Diff @@
## master #606 +/- ##
==========================================
- Coverage 50.95% 50.75% -0.20%
==========================================
Files 219 220 +1
Lines 15951 16102 +151
==========================================
+ Hits 8128 8173 +45
- Misses 6684 6786 +102
- Partials 1139 1143 +4
Continue to review full report at Codecov.
|
cmd/completion.go
Outdated
" >> $HOME/.bash_profile | ||
source $HOME/.bash_profile | ||
|
||
|
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.
Does here need two blank lines? can we just retain one blank line?
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.
Done
cmd/completion.go
Outdated
case "zsh": | ||
return genCompletionZsh(os.Stdout, cmd.Parent()) | ||
default: | ||
return errors.New("Unsupported shell type " + args[0]) |
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.
The error should begin with the lower-case according to Golang idiomatic.
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.
Done
@yeya24 Awesome works. is there any way for components completion? e.g:
|
Signed-off-by: Ben Ye <yb532204897@gmail.com>
a5de6e3
to
3894e0d
Compare
To be honest I don't know how to support that. |
@lonng Can I ask why the CI test failed? Is it related to this change? |
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.
LGTM
@yeya24 Our global CDN doesn't work very well at this time, so the CI may fail on the network issue (and retry will success). We are trying to fix this. |
make bash-autocompletion works for tiup components(ie. cluster, br). Current TiUP native bash-autocompletion does not support them Refer pingcap/tiup#606 - `cluster` and `br` compoments supported, others may be coming - Usage ``` $ source /path/to/tiup_completion.bash $ tiup <TAB> bench cdc client completion dm env help list pd-recover status tidb uninstall br clean cluster ctl dmctl errdoc install mirror playground telemetry tidb-lightning update $ tiup c<TAB> cdc clean client cluster completion ctl $ tiup cluster <TAB> audit clean destroy display enable import patch reload replay scale-in start template check deploy disable edit-config help list prune rename restart scale-out stop upgrade ``` Thanks to https://stackoverflow.com/questions/17879322/how-do-i-autocomplete-nested-multi-level-subcommands
Signed-off-by: Ben Ye yb532204897@gmail.com
What problem does this PR solve?
Fixes #73
What is changed and how it works?
Add a
tiup completion [bash | zsh]
command.Check List
Tests
Code changes
Side effects
Related changes