Skip to main content
argtools
==========

Description
-------------------
Just a wrapper of argparse module which is included in Python standard libraries for ver. >= 2.7.
Argtools helps you to build command line tools with *minimal effort*.

Quick start
-------------------

### Installation
```sh
$ pip install argtools
```

### Basic usage

```python
# examples/test.py
from argtools import command, argument

@command
@argument('foo', help='a positional arugment')
@argument('--bar', default=3, help='an optional argument')
def main(args):
""" One line description here

Write details here (printed with --help|-h)
"""
print args.bar
print args.foo
return 1 # return code


if __name__ == '__main__':
command.run()
```

```sh
$ python test.py
$ python test.py -v # It setups logging module internally and has verbose mode
```

The argument function has same api as argparse.ArgumentParser.add_argument.
(see http://docs.python.org/dev/library/argparse.html for detail.)


### Creating subcommands

```python
# examples/subtest.py
from argtools import command, argument

@command.add_sub
def foo(args):
""" This is foo
"""
print 'foo'


@command.add_sub
def bar(args):
""" This is bar
"""
print 'bar'


@command.add_sub(name=baz) # set different name
def bar(args):
""" This is baz
"""
print 'baz'

if __name__ == '__main__':
command.run()
```

```sh
$ python test.py foo # print foo
$ python test.py bar # print bar
$ python test.py bar -h # print help text of bar subcommand
```


Features
-------------------

- command.run setups logging module internally and can control verbosity like -v, -vv, ..
- command.run ignores SIGPIPE occured inside of wrapped function
- It supports group or exclusive arguments by argument.group, argument.exclusive (documentation is #TODO)
- Builtin options (-v, --verbose, --debug) can be turned off by setting command.add_verbose = False or command.add_debug = False


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argtools-0.1.5.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file argtools-0.1.5.tar.gz.

File metadata

  • Download URL: argtools-0.1.5.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for argtools-0.1.5.tar.gz
Algorithm Hash digest
SHA256 69504f58939dee8d96898212d985fb5b72fcec05537d464212772ee9ae6372a9
MD5 fd6c59cbe39c242c3fa48a1b030bb9a5
BLAKE2b-256 95c484b21c32f8602f06f0f1856595ccc2ba032dfcea800d317271f04fd17359

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.6

1 file

This release

0.1.5 This release

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page