-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Bash completions for etcdctl #2892
Conversation
This is a WIP because I didn't immediately know how to handle |
Also I realize I'll have to handle godeps 'the coreos' way. But I already opened another PR (#2893) to try to fix etcd's Godeps before I try to add more! I could include that fix here, and give the complete solution, but review would be harder... |
in case you want to try the results without fighting through building this code: wget https://gist.githubusercontent.com/eparis/2380a2daa7ff6c0b52a6/raw/bdd185d78428b2fc9f97172066a9b4c29f9ff57d/gistfile1.sh
. gistfile1.sh
etcdctl [tab][tab] |
updated, now with godeps, so building is easier/possible |
//handleError(ErrorFromEtcd, err) | ||
//} | ||
//n += copyKeys(allh.Node, setc) | ||
//} |
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.
THIS MUST BE FIXED BEFORE MERGE
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.
yea... another thing I noticed is that cobra does not support slice.
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.
https://github.com/eparis/pflag/tree/SliceStrings
Has support for string slices. I can define it in the etcdctl code, but that'd suck, so i'd consider this a prereq before I remove the WIP....
@eparis I used cobra in my side project. I found it is a little bit annoying (maybe it is configurable or my memory is wrong) is that I need to use "=" to separate the flag and the value if I use the long flag (--flag). If I use short flag, it behaviors differently and unexpectedly. For example. I have a short flag "-d". If I use "-data", it will set -d flag to ata... |
spf13/pflag#20 has a fix to the --flag "bob" not working. I can probably poke steve to see what he thinks about me fixing it (add adding optional args at the same time) -data is 'expected' if -d isn't a boolean... i don't see a way 'fix' that.... |
@eparis My argument is short and long behavior differently... Look this, I have a flag (data, d). The app simply prints out the flag value.
|
@xiang90 that's called posix flag parsing. I get it, but that's the way unix does it. Which is why I don't think it can be 'fixed'
|
@eparis OK. So I will be happy to take a further look at this when:
Sounds good? |
did you play with the completion? was it useful enough for me to keep pushing? (at the least --foo "bob" needs fixed no matter what!) |
0eecc95
to
a276035
Compare
All comments should be addressed and this should be g2g.... |
@eparis This is too late for 2.1. Can you send a pull request to dev 2.2 branch? |
@eparis Any updates on this? BTW, we have migrated to Please check that out if you have time. |
Closing this since it is inactive. |
@eparis a pitty this hasn't gone in. I'd love to have etcdctl bash completion. Any chance you pick this up again and try to push this into etcd? |
This does 2 things. First is ports from codegansta/cli to spf13/cobra.
Second it uses spf13/cobra to generate intelligent bash completions for etcdctl. The are generated by running
etcdctl genbash --outfile=yourfile
and then sourcing the file. yourfile
(or you could put the output in/etc/bash_completion.d/
or/usr/share/bash-completion/completions/
and have it automatically loaded.)These completions are pretty cool because on my machine you can do obvious simple things:
But it also will show you data on 127.0.0.1!
It is NOT smart enough to use things you already types on your command line, so --peers etc aren't used trying to show the completions. Only loopback.