Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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: GitHub / PyPi


version 0.4.3:

  • [change] no more locals under docpie function as it may lead to unexpected behavior

full changelog & TODOs


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: [options] <source_file> <target_file> [options] <source_file>... <target_directory>

  -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__)

Now run it

$ python 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 >>


Install release version:

pip install docpie

Install nightly/dev version:

pip install git+

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 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.


the code in is taken from tornado, and is from python Cookbook

Many examples & tests are from docopt.


docpie is released under MIT-License

Project details

Download files

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

Files for docpie, version 0.4.3
Filename, size File type Python version Upload date Hashes
Filename, size docpie-0.4.3-py2.py3-none-any.whl (69.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size docpie-0.4.3.tar.gz (65.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page