Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Functionality akin to <a href="http://pypi.python.org/pypi/plac" rel="nofollow"><code>plac</code></a> is provided by <a href="http://pypi.python.org/pypi/argh" rel="nofollow">argh</a>, which particularly features simple creation of subparsers (like those found in <code>git</code> or <code>django-admin.py</code>).</p> <p>An example from its <a href="http://packages.python.org/argh" rel="nofollow">docs</a>:</p> <pre><code>from argh import * def dump(args): return db.find() @command def load(path, format='json'): print loaders[format].load(path) p = ArghParser() p.add_commands([load, dump]) if __name__ == '__main__': p.dispatch() </code></pre> <p>Produces the following <code>--help</code> response:</p> <pre><code>usage: prog.py [-h] {load,dump} ... positional arguments: {load,dump} load dump optional arguments: -h, --help show this help message and exit </code></pre> <p>and the following with <code>load --help</code>:</p> <pre><code>usage: prog.py load [-h] [-f FORMAT] path positional arguments: path optional arguments: -h, --help show this help message and exit -f FORMAT, --format FORMAT </code></pre> <p>Arguments may be annotated:</p> <pre><code>@arg('path') @arg('--format', choices=['yaml','json'], default='json') @arg('--dry-run', default=False) @arg('-v', '--verbosity', choices=range(0,3), default=1) def load(args, LOADERS={'json': json.load, 'yaml': yaml.load}): loader = loaders[args.format] data = loader(open(args.path)) ... </code></pre> <p>And with <code>@plain_signature</code>, the <code>args</code> argument to <code>load</code> is expanded into keyword arguments:</p> <pre><code>@arg('path') @arg('--format', choices=['yaml','json'], default='json') @arg('--dry-run', default=False) @arg('-v', '--verbosity', choices=range(0,3), default=1) @plain_signature def load(path, format, dry_run, verbosity): ... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload