# argh / docs / index.rst

## Agrh, argparse!

Did you ever say "argh" trying to remember the details of optparse or argparse API? If yes, this package may be useful for you.

Argh provides a very simple wrapper for argparse. Argparse is a very powerful tool; argh just makes it easy to use.

### In a nutshell

Here's a list of features that argh adds to argparse:

• mark a function as a CLI command and specify its arguments before the parser is instantiated;
• nested commands made easy: no messing with subparsers (though they are of course used under the hood);
• infer command name from function name;
• infer agrument type from the default value;
• infer argument action from the default value (for booleans);
• infer arguments from function signature;
• add an alias root command help for the --help argument;
• enable passing unwrapped arguments to certain functions instead of a :class:argparse.Namespace object.

Argh is fully compatible with argparse. You can mix argh-agnostic and argh-aware code. Just keep in mind that :func:~argh.helpers.dispatch does some extra work that a custom dispatcher may not do.

### Dependencies

The argh library is supported (and tested unless otherwise specified) on the following versions of Python:

• 2.6 (argparse library is required)
• 2.7 (including PyPy 1.8)
• 3.1 (argparse library is required; not tested)
• 3.2

### Stability

Argh is well-tested (could be better but still 80-100% test coverage).

The API may change in the future but there are no such plans yet.

### Similar projects

• argdeclare requires additional classes and lacks support for nested commands.
• django-boss seems to lack support for nested commands and is strictly Django-specific.
• entrypoint is lightweight but involves a lot of magic and seems to lack support for nested commands.
• opster and finaloption support nested commands but are based on the outdated optparse library and therefore reimplement some features available in argparse. They also introduce decorators that don't just decorate functions but change their behaviour, which is bad practice.
• simpleopt has an odd API and is rather a simple replacement for standard libraries than an extension.
• opterator is based on the outdated optparse and does not support nested commands.
• clap ships with its own parser and therefore is incompatible with clap-agnostic code.
• plac is a very powerful alternative to argparse. I'm not sure if it's worth migrating but it is surely very flexible and easy to use.

### Author

Developed by Andrey Mikhaylenko since 2010.

See :file:AUTHORS for a complete authors list of this application.

Please feel free to submit patches, report bugs or request features:

http://bitbucket.org/neithere/argh/issues/