Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install argh

How to install argh

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install argh
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.23.3 Available View build log
0.19.0 Available View build log
0.16.0 Available View build log
0.15.1 Available View build log
0.15.0 Available View build log
0.14.2 Available View build log
0.14.1 Available View build log
0.14.0 Available View build log
0.13.0 Available View build log
0.12.0 Available View build log
0.11.0 Available View build log
0.10.1 Available View build log
0.10.0 Available View build log
0.8.1 Available View build log
0.8.0 Available View build log
0.7.0 Available View build log
0.6.0 Available View build log
0.5.2 Available View build log
0.4.0 Failed View build log
0.2.0 Available View build log
0.15.1
0.23.3Never BuiltWhy not?
0.15.1 Available View build log
Windows (64-bit)
0.23.3 Available View build log
0.16.0 Available View build log
0.15.1 Available View build log
0.15.0 Available View build log
0.14.2 Available View build log
0.14.1 Available View build log
0.14.0 Available View build log
0.13.0 Available View build log
0.12.0 Available View build log
0.11.0 Available View build log
0.10.1 Available View build log
0.10.0 Available View build log
0.8.1 Available View build log
0.8.0 Available View build log
0.7.0 Available View build log
0.6.0 Available View build log
0.5.2 Available View build log
0.4.0 Failed View build log
0.2.0 Available View build log
0.15.1
0.23.3Never BuiltWhy not?
0.15.1 Available View build log
Mac OS X (10.5+)
0.23.2
0.23.3Never BuiltWhy not?
0.23.2 Available View build log
0.17.2 Available View build log
0.16.0 Available View build log
0.15.1 Available View build log
0.15.0 Available View build log
0.14.2 Available View build log
0.14.1 Available View build log
0.14.0 Available View build log
0.13.0 Available View build log
0.12.0 Available View build log
0.11.0 Available View build log
0.10.1 Available View build log
0.10.0 Available View build log
0.8.1 Available View build log
0.8.0 Available View build log
0.7.0 Available View build log
0.6.0 Available View build log
0.5.2 Available View build log
0.4.0 Failed View build log
0.2.0 Available View build log
0.15.1
0.23.3Never BuiltWhy not?
0.15.1 Available View build log
0.15.0 Available View build log
Linux (32-bit)
0.23.3 Available View build log
0.23.2 Available View build log
0.19.0 Available View build log
0.18.0 Available View build log
0.17.2 Available View build log
0.16.0 Available View build log
0.15.1 Available View build log
0.15.0 Available View build log
0.14.2 Available View build log
0.14.1 Available View build log
0.14.0 Available View build log
0.13.0 Available View build log
0.12.0 Available View build log
0.11.0 Available View build log
0.10.1 Available View build log
0.10.0 Available View build log
0.8.1 Available View build log
0.8.0 Available View build log
0.7.0 Available View build log
0.6.0 Available View build log
0.5.2 Available View build log
0.4.0 Failed View build log
0.2.0 Available View build log
0.15.0
0.23.3Never BuiltWhy not?
0.15.0 Available View build log
Linux (64-bit)
0.23.3 Available View build log
0.23.2 Available View build log
0.21.1 Available View build log
0.19.0 Available View build log
0.17.2 Available View build log
0.17.1 Available View build log
0.16.0 Available View build log
0.15.1 Available View build log
0.15.0 Available View build log
0.14.2 Available View build log
0.14.1 Available View build log
0.14.0 Available View build log
0.13.0 Available View build log
0.12.0 Available View build log
0.11.0 Available View build log
0.10.1 Available View build log
0.10.0 Available View build log
0.8.1 Available View build log
0.8.0 Available View build log
0.7.0 Available View build log
0.6.0 Available View build log
0.5.2 Available View build log
0.4.0 Failed View build log
0.2.0 Available View build log
0.15.0
0.23.3Never BuiltWhy not?
0.15.0 Available View build log
0.23.3 Available View build log
0.23.2 Available View build log
0.23.0 Available View build log
 
License
GNU Lesser General Public License (LGPL), Version
Imports
Lastest release
version 0.23.3 on Aug 23rd, 2013

Building a command-line interface? Found yourself uttering "argh!" while struggling with the API of argparse? Don't want to lose its power but don't need the complexity?

Everything should be made as simple as possible, but no simpler.

—Albert Einstein (probably)

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

In a nutshell

Argh-powered applications are simple but flexible:

Modular:

Declaration of commands can be decoupled from assembling and dispatching;

Pythonic:

Commands are declared naturally, no complex API calls in most cases;

Reusable:

Commands are plain functions, can be used directly outside of CLI context;

Layered:

The complexity of code raises with requirements;

Transparent:

The full power of argparse is available whenever needed;

Namespaced:

Nested commands are a piece of cake, no messing with subparsers (though they are of course used under the hood);

Term-Friendly:

Command output is processed with respect to stream encoding;

Unobtrusive:

Argh can dispatch a subset of pure-argparse code, and pure-argparse code can update and dispatch a parser assembled with Argh;

DRY:

The amount of boilerplate code is minimal; among other things, Argh will:

  • infer command name from function name;
  • infer arguments from function signature;
  • infer argument type from the default value;
  • infer argument action from the default value (for booleans);
  • add an alias root command help for the --help argument.

Sounds good? Check the tutorial!

Relation to argparse

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

Installation

Using pip:

$ pip install argh

Arch Linux (AUR):

$ yaourt python-argh

Examples

A very simple application with one command:

System Message: ERROR/3 (<string>, line 82)

Unknown directive type "code-block".

.. code-block:: python

    import argh

    def main():
        return 'Hello world'

    argh.dispatch_command(main)

A potentially modular application with multiple commands:

System Message: ERROR/3 (<string>, line 93)

Unknown directive type "code-block".

.. code-block:: python

    import argh

    # declaring:

    def echo(text):
        return text

    def greeter(name, greeting='hello'):
        return greeting + ', ' + name

    # assembling:

    parser = argh.ArghParser()
    parser.add_commands([echo, greeter])

    # dispatching:

    if __name__ == '__main__':
        parser.dispatch()

The powerful API of argparse is also available:

System Message: ERROR/3 (<string>, line 117)

Unknown directive type "code-block".

.. code-block:: python

    @arg('text', default='hello world', nargs='+', help='The message')
    def echo(text):
        print text

The approaches can be safely combined even up to this level:

System Message: ERROR/3 (<string>, line 125)

Unknown directive type "code-block".

.. code-block:: python

    # adding help to `foo` which is in the function signature:
    @arg('foo', help='blah')
    # these are not in the signature so they go to **kwargs:
    @arg('baz')
    @arg('-q', '--quux')
    # the function itself:
    def cmd(foo, bar=1, *args, **kwargs):
        yield foo
        yield bar
        yield ', '.join(args)
        yield kwargs['baz']
        yield kwargs['quux']

Author

Developed by Andrey Mikhaylenko since 2010.

See file AUTHORS for a complete list of contributors to this library.

Licensing

Argh is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Argh is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with Argh. If not, see <http://gnu.org/licenses/>.

Subscribe to package updates

Last updated Aug 23rd, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.