kadirpekel/komandr — pull request #2 by everbird (2013-01-13 11:38:24+00:00)
Title: Default subcommand if no one specified

I would like go write some script without subcommand like this:

```python
def run(args):
print args.foo

if __name__ == __main__:
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--foo', help='bar', default='baz')
args = parser.parse_args()
run(args)
```
So that I can just simply run `./script.py`.

But I found it's hard to achieve this using `komandr`. Because `self.parser.add_subparsers()` in the constructor make the subcommand a must. So I did a little hack to make the script work like this:

```python
@komandr.arg('foo', '-f', '--foo', help='baz')
def run(foo='bar'):
print foo

if __name__ == __main__:
komandr.main(default_subcommand='run')
```

The specified default subcommand would be called unless the first argument was `--help` or `--version` or other options which registed to the parser at first.

`komandr` is cool and I hope this a little hack would help to make it better.

Cheers