doing
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.
Contents
[TOC]
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/__main__.py:
#!/usr/bin/env python3
import doing
import sample
if __name__ == '__main__':
doing.do_main(sample)
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
Finally:
$ python -m sample greet english Hello! $ python -m sample greet spanish Hola!
Adding an executable script called do, with contents like those of __main__.py will let you do:
$ ./do greet english Hello! $ ./do greet spanish Hola!
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 mymodule.py or mypackage/__init__.py.
To enable doing for a top-level package, either provide a __main__.py 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 __init__.py.
This is the contents of sample/greet/spanish.py:
"""
greet in Spanish
"""
def do():
print('Hola!')
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
end
Metadata
Release files for doing 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| doing-1.0.0.zip | 11.6 kB | Without provenance | Details for doing-1.0.0.zip | |
| doing-1.0.0.tar.gz | 5.7 kB | Without provenance | Details for doing-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| doing-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for doing-1.0.0-py2.py3-none-any.whl |
Total release size: 24.3 kB
Release files / doing-1.0.0.zip
| Download URL | doing-1.0.0.zip |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf797a73980ebd1a0f865cfe77cad8655a059ecc0901d6ef53b7b58e295bc465
|
|
BLAKE2b-256 checksum How to use checksums |
f48e658d3ca2da179316bf8d600d483286e63bad0ba292d79109cd64b71135f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / doing-1.0.0.tar.gz
| Download URL | doing-1.0.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9345bd365f9069575b32c652a105f02c38f7b9915e897815e027deff0d6492b9
|
|
BLAKE2b-256 checksum How to use checksums |
d115b6e479dcce6f7c085cf6edc27b711877eb01deb04f5cd195e514c91410a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / doing-1.0.0-py2.py3-none-any.whl
| Download URL | doing-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7b481e88ffe921110f1640f69c0a6b3a7559c5076c440d62281d84913b188fcc
|
|
BLAKE2b-256 checksum How to use checksums |
6f7ae6ed64e4241281ac700eae3351f9095a59b7e9c1c24773921a8746b720e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for doing 1.0.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.