Alexey Serbin has posted comments on this change. Change subject: tool: better handling for positional arguments ......................................................................
Patch Set 1: > (11 comments) > > > Sure wish there was some test coverage on these tools... > > Alright, you got me. I'll add some in another patch. > > > There is a Go library which allows to implement rich CLI tools. > If > > using the library it's really easy to document the > > commands/sub-commands/parameters and it provides tab-completion > > support for shell as an additional feature. It might be useful > to > > take a look at that: > > https://www.progville.com/go/cli-go-better-command-line-applications-go/ > > https://github.com/urfave/cli > > > > There is even more powerful library named Cobra: > > https://github.com/spf13/cobra > > > > We implemented very decent command-line tool using > codegangsta/cli > > library in one of prior projects. > > > > Also, if talking about command-line tools: given the abundance of > > CLI libraries, it might make sense to consider an option to > > implement those in Go. It's really fast and simple in > development > > and seems to be the perfect language choice for that sort of > > things. > > Thanks for pointing me at those. I took a quick look at cli, and > it's encouraging to see that it uses largely the same patterns that > this tool does: actions nested under verbs, each of which is mapped > to a function. > > As for writing the tool in Go, Dan asked me the same question (but > about Python). I wanted to use C++ because I wanted to avoid > introducing a runtime dependency (this is mostly a knock against > Python, since Go programs are statically linked), and I wanted to > make it super easy to call into our existing C++ code. > > > Also, if it makes sense to exercise bash completion to in > > displaying available sub-commands, it would also make sense to > > check that. Basically, it's about outputting the available > > sub-commands if given --enable-bash-completion option at any > level. > > Didn't know this. Am I understanding you correctly: if a program > responds to --enable-bash-completion with a list of verbs, then > bash will invoke that behind the user's back when they try to tab > complete? That is, if I run "kudu <TAB>", bash will try to run > "kudu --enable-bash-completion" to figure out what the possible > completions are? Yes, that's the idea. The bash can use different option. Actually, an additional .bashrc customization will be necessary. For details, please take at https://github.com/urfave/cli/blob/master/autocomplete/bash_autocomplete -- To view, visit http://gerrit.cloudera.org:8080/4013 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic6aa517ccf1915e4d106bcc5f80a3abfeae03271 Gerrit-PatchSet: 1 Gerrit-Project: kudu Gerrit-Branch: master Gerrit-Owner: Adar Dembo <a...@cloudera.com> Gerrit-Reviewer: Adar Dembo <a...@cloudera.com> Gerrit-Reviewer: Alexey Serbin <aser...@cloudera.com> Gerrit-Reviewer: Dan Burkert <d...@cloudera.com> Gerrit-Reviewer: Kudu Jenkins Gerrit-Reviewer: Todd Lipcon <t...@apache.org> Gerrit-HasComments: No