This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Command Line Interface Helper

This is a helper module for making intuitive command line programs with zero effort. It takes a function signature like:

example_function(string1, string2='something', string3='something else')

and turns it into a simple command-line app with usage:

example_program string1 [string2 [string3]]

All you have to do is:

if __name__ == "__main__":
   import commandline
   commandline.run_as_main(example_function)

Limitations

Note that it currently can’t print help information for arguments other than their default values, but it will print your docstring for you if that’s of any use.

Help for arguments will probably come with python3000’s function annotations. http://www.python.org/dev/peps/pep-3107/

Argument types are inferred from the default arguments. Currently supported are: int, float, bool, str, commandline.Choice

If things don’t have a default argument, I can’t infer the type so assume str.

>>> import commandline
>>> commandline.TESTMODE=1
>>> def test1(arg1=1, arg2=2, arg3=3):
...     print [arg1, arg2, arg3]
...
>>> commandline.run_as_main(test1, [])
[1, 2, 3]
>>> commandline.run_as_main(test1, ['6'])
[6, 2, 3]
>>> commandline.run_as_main(test1, ['--arg1=6', '--arg2=7', '--arg3=8'])
[6, 7, 8]
>>> commandline.run_as_main(test1, ['6', '7', '8'])
[6, 7, 8]
>>> commandline.run_as_main(test1, ['6', '7', '8', '9'], 'test.py')
Usage: test.py [arg1 [arg2 [arg3]]] [Options]
<BLANKLINE>
(Please put options last, and no more args than shown.)
Unexpected argument(s): 9
>>> commandline.run_as_main(test1, ['--arg1=6', '7', '8'], 'test.py')
Usage: test.py [arg1 [arg2 [arg3]]] [Options]
<BLANKLINE>
(Please put options last, and no more args than shown.)
Unexpected argument(s): 7, 8
>>> def test2(arg1=1, arg2=2, arg3=3):
...     return [arg1, arg2, arg3]
...
>>> commandline.run_as_main(test2, ['6', '7', '8'])
[6, 7, 8]
>>> def nodefault(arg1, arg2, arg3):
...     return [arg1, arg2, arg3]
>>> # If we have no default arguments, we assume you want strings:
>>> commandline.run_as_main(nodefault, ['6', '7', '8'])
['6', '7', '8']
>>> commandline.run_as_main(nodefault, [], 'test.py')
Usage: test.py arg1 arg2 arg3 [Options]
<BLANKLINE>
The following compulsory arguments are missing: arg1, arg2, arg3
Release History

Release History

0.1.4dev

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
commandline-0.1.4dev-py2.6.egg (15.1 kB) Copy SHA256 Checksum SHA256 2.6 Egg Jun 13, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting