Skip to main content

doing implements hierarchical command lines

Project description


Hierarchical command lines in python.

doing enables the simple creation of simple hierarchical command lines in Python programs.

It was originally designed to make it easy to create small Python tools that took the place of bash scripts in system maintenance, so the library assumes that packages and modules with names that do not start with an underscore are either commands or containers of sub-commands.



This is what you do

If the doing distribution is uncompressed to a directory, you’ll find a sample command-line program n the Python executable package called… sample.

This is the source code for sample/

#!/usr/bin/env python3
import doing
import sample

if __name__ == '__main__':

And this is what doing enables:

$ python -m sample
sample v1.0.0rc1 a sample hierarchical command line created with the doing package

    sample greet ...        greet in several languages
    sample version          display the version

Issuing a sub-command:

$ python -m sample version
version 1.0.0rc1

As sub-command with sub-sub-commands:

$ python -m sample greet
sample.greet  greet in several languages

    sample greet english    greet in English
    sample greet spanish    greet in Spanish


$ python -m sample greet english
$ python -m sample greet spanish

Adding an executable script called do, with contents like those of will let you do:

$ ./do greet english
$ ./do greet spanish

Implementing the doing command line

doing assumes that all packages and modules are potential commands or sub-commands. The description of the command is taken from the modules doc-comment (in or mypackage/

To enable doing for a top-level package, either provide a or a do (or any other script name) as described in the introduction.

For modules and packages that execute some action, write a def do(): method in the module or in the packages

This is the contents of sample/greet/

greet in Spanish

def do():

If doing finds that a command has modules implementing sub-commands, it will indicate so on the command help with an ellipsis:

sample greet ...        greet in several languages


Project details

Download files

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

Source Distributions (11.6 kB view hashes)

Uploaded source

doing-1.0.0.tar.gz (5.7 kB view hashes)

Uploaded source

Built Distribution

doing-1.0.0-py2.py3-none-any.whl (7.0 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page