google / subcommands

Go subcommand library.
Apache License 2.0
749 stars 48 forks source link

Adds aliaser command #14

Closed donatj closed 6 years ago

donatj commented 6 years ago

I would like to be able to have the same code on multiple commands, namely list and ls.

I've been using roughly this "Aliaser" in my own code - I thought other people might get some use out of it and figured it would be worth opening a pull request.

thomasf commented 6 years ago

While it does change semantics I think it would be better if Name() were allowed to specify multiple names, maybe comma separated? If a feature like this would be added the default list/help-commands feature should be updated to print the help page better without just repeating the same command multiple times..

donatj commented 6 years ago

My 2¢ if we're making breaking interface changes, I'd put name as a parameter of subcommands.Register rather than on the Command interface, but I imagine that's way out of scope.