tj / commander

The complete solution for Ruby command-line executables
http://visionmedia.github.com/commander
MIT License
1.09k stars 64 forks source link

Documentation on how to create composite commands #78

Closed rmiesen closed 10 years ago

rmiesen commented 10 years ago

I created documentation on how to create composite commands using commander and I feel that others would benefit from knowing how to do this.

ggilder commented 10 years ago

Thanks for the addition! It seems that there are some extra commits on this branch that don't relate to your change, could you rebase it and get it down to the one relevant commit?

rmiesen commented 10 years ago

I think I fixed the problem now.

ggilder commented 10 years ago

Hmm, I'm still seeing 6 commits here where there should only be one. However, I took a closer look at the example code and I think there's a bigger problem — it implies features that don't actually work :frowning:

Commander does let you create composites of simple commands (ones that take no options) but the prefix and suffix options in this example actually have no effect on the invocation of bar. I think I'm going to close this pull request for now; there are ways to hack around it but I'm not sure it makes sense to encourage that.

Can you give some examples of where this type of feature would be useful? Maybe open an issue describing the use cases.

rmiesen commented 10 years ago

Actually, I am thinking that this "use case" is more of a symptom of "Golden Hammer syndrome." A more correct approach for executing a "foobar" command was to put the execution logic of "foo" and "bar" into helper methods and execute them as appropriate.

Thanks for your time and your help ggilder!