An easy and Pythonic way to create your POSIX command line interface
Project description
An easy and Pythonic way to create your POSIX command line
View on: HomePage / GitHub / PyPi
ChangeLog
version 0.2.7:
[fix] a typo which will cause failed to throw an error when there is an syntax error in your help message
[fix] #3
Summary
How do you define your command line interface? Write a parse by yourself or spend hours learning optparse / argparse , and modify both code side and document every time you update the interface?
Life is short, man! You can simply do it this way:
"""
My copy script
Usage:
cp.py [options] <source_file> <target_file>
cp.py [options] <source_file>... <target_directory> <log_file>
Options:
-h -? --help print this screen
--version print the version of this script
-v --verbose print more information while running
"""
from docpie import docpie
args = docpie(__doc__)
print(args)
Now run it
$ python cp.py a.txt b.txt c.txt /tmp cp.log
{'--': False,
'--help': False,
'--verbose': False,
'--version': False,
'-?': False,
'-h': False,
'-v': False,
'<log_file>': 'cp.log',
'<source_file>': ['a.txt', 'b.txt', 'c.txt'],
'<target_directory>': '/tmp',
'<target_file>': None}
Write a __doc__, pass it to a function, DONE! Isn’t it simple?
Installation
Install release version:
pip install docpie
Install nightly/dev version:
pip install git+git://github.com/TylerTemp/docpie.git
docpie has been tested with Python:
2.6, 2.7
3.2, 3.3, 3.4, 3.5
pypy-2.0, pypy-2.6, pypy3-2.4
Get Start!
Interested? Visit Document and get start!
Or you can try it in your browser
Why docpie?
docpie can greatly reduce the work you need to be done for command-line interface. What you see is what you get. Every time you only need to update your document, and keep the code unchanged.
See here for more reasons.
Reference
the code in bashlog.py is taken from tornado, and tracemore.py is from python Cookbook
Many examples & tests are from docopt.
License
docpie is released under MIT-License
Donate
If you like this project, you can buy me a beer so I can make it better!
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
Built Distributions
Hashes for docpie-0.2.7.macosx-10.10-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e1d52282741e44612b6a06606175155117b6493aa6ae68ef2c23298b320afe2 |
|
MD5 | 7d235e6729fd1856a5249309a4f4d86d |
|
BLAKE2b-256 | 37841111e83388cceac9ef5b9aed6798e6a1aab52c1983fc5c4d061b45651888 |
Hashes for docpie-0.2.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ecc92323f9e2446ef88545a0b2c21317b817405443bc19f0ec7af527809479e |
|
MD5 | 6fe5db9847aa0e3bf8bb42a0649a5b73 |
|
BLAKE2b-256 | c4673c63d0989ad786ca964f418dc3ce2115f049e32b011b75ae5be9fd634567 |