epsy/clize — pull request #1 by ksamuel (2012-02-12 16:23:03+00:00)
Title: Basic subcommand implementation

Hello,

I'm a big fan of clize and wanted to have its power and simplicity available to create subcommands.

I took a shot at adding this feature.

The initial API doesn't change, the only difference being that if you pass a list of functions instead of a function to run(), it will take each function and turn it into a subcommand.

The usage message is then adapted on the fly.

Implementing this didn't took much code but:

- I had to attach a string to the 'run' function object with the name of the current subcommand, since I couldn't find any easy way to make the information cascade to the help function.
- I tried to code some unit tests, but any attemp to do it would fail because no encoding is declared on the file and strings don't use unicode, so self.assertEqual fails. Obviously our systems don't use the same encoding.

All the previous unit tests still pass. I updated the README.rst with an example on how to use subcommands.

BTW, the .gitignore file was a dead link, not a real file. I replaced it as well.

I hope you'll like it.

Cheers

P.S: there is a subcommands branch on my repo if you want to test that first.