Skip to main content

An easy and Pythonic way to create your POSIX command line

View on: GitHub / PyPi

https://travis-ci.org/TylerTemp/docpie.svg?branch=master

ChangeLog

version 0.4.4:

change auto balance function, fix the issue that won’t work for this case

"""
Usage:
    cp [options] <source>... <target>

Options:
    -R
"""

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>

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
{'--': False,
 '--help': False,
 '--verbose': False,
 '--version': False,
 '-?': False,
 '-h': False,
 '-v': False,
 '<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?

try it >>

Installation

Install release version:

pip install docpie

Install nightly/dev version:

pip install git+https://github.com/TylerTemp/docpie.git@dev

docpie has been tested with Python:

  • 2.6, 2.7, pypy-2.0, pypy-2.6

  • 3.2, 3.3, 3.4, 3.5, pypy3-2.4

You can run test suit by python setup.py test

Get Start!

Interested? Visit Wiki 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!

https://dn-tyler.qbox.me/alipay.ico https://button.flattr.com/flattr-badge-large.png

Metadata

Release files for docpie 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docpie 0.4.4
File Size Uploaded Provenance
docpie-0.4.4.tar.gz 66.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docpie 0.4.4
File Interpreter ABI Platform
docpie-0.4.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 136.7 kB

Release files / docpie-0.4.4.tar.gz

Download URL docpie-0.4.4.tar.gz
Size 66.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c17cad09698a03e00174df1cc21090af88668f07ba854954fe81065873258bb6
BLAKE2b-256 checksum
How to use checksums
83429b0b88affd76778b2dd88a15d930c8d84e45e20fe843c5305ec5b35bc443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / docpie-0.4.4-py2.py3-none-any.whl

Download URL docpie-0.4.4-py2.py3-none-any.whl
Size 70.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c868a465dfc69b8b71a564761ff69d42652268672fafd58f0f596a47e481e809
BLAKE2b-256 checksum
How to use checksums
200787705358040cdedef5c79463f756798be498a88de43096b6e07362158e0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for docpie 0.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files No provenance

0.0.4

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page