Exposes your APIs to the command line.
Project description
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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
commandline-0.1.2dev.tar.gz
(5.4 kB
view hashes)
Built Distributions
commandline-0.1.2dev-py2.5.egg
(15.7 kB
view hashes)
Close
Hashes for commandline-0.1.2dev.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 269a559d4ef8805ad5e3b5a1cd55e8a00f95c4be4b65671003b0f21c4d5289c1 |
|
MD5 | cf6af4d5c7a89d5df74469a370df508d |
|
BLAKE2b-256 | 1816737abfd73d5201b5db516830b3e0e0d7fc46a593959b45b0f9ac7b862c1d |