nutcli - cli in a nutshell
The Python nutcli package allows you to easily create robust command-based
command line interface that can combine the best of the two worlds of
python and shell.
It also provides several useful classes and decorators that can help you improve the user experience by producing nicely formatted output and allowing dry runs for operations with side effects.
Links
- Project source code: https://github.com/pbrezina/python-nutcli
- Project documentation: https://nutcli.readthedocs.io
- Project at PyPi: https://pypi.org/project/nutcli
Installation
pip3 install nutcli
Example instead of thousands words
Bellow is the very basic example to get the idea of what this package does and how its used.
class HelloActor(Actor):
def setup_parser(self, parser):
parser.add_argument('--hello', action='store', type=str)
def __call__(self, hello):
self.info(hello)
return 0
class Program:
def main(self, argv):
# Create argument parser.
parser = argparse.ArgumentParser()
CommandParser('Example Commands')([
Command('hello', 'Print hello message', HelloActor()),
]).setup_parser(parser)
# Create the runner object.
runner = Runner('my-cli', parser).setup_parser()
# Parse arguments - the runner internally process its own arguments
# that were setup by previous call to `setup_parser()`.
args = runner.parse_args(argv)
# You can handle your own global arguments here.
# Now we setup the default logger - it produces output to stdout
# and stderr.
runner.default_logger()
# And finally, we execute the requested command and return its exit
# code.
return runner.execute(args)
if __name__ == "__main__":
program = Program()
sys.exit(program.main(sys.argv[1:]))
$ python3 ./main.py hello --hello world
[my-cli] world
$ python3 ./main.py --help
usage: main.py [-h] [--log-execution] [--dry-run] [--no-colors] COMMANDS ...
optional arguments:
-h, --help show this help message and exit
--log-execution Log execution of operations that supports it.
--dry-run Do not execute operations with side effects. Only log what
would be done.
--no-colors Do not execute operations with side effects. Only log what
would be done.
Example Commands:
COMMANDS
hello Print hello message
Metadata
Release files for nutcli 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nutcli-1.2.tar.gz | 33.4 kB | Without provenance | Details for nutcli-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nutcli-1.2-py3-none-any.whl | Python 3 | none | any | Details for nutcli-1.2-py3-none-any.whl |
Total release size: 69.6 kB
Release files / nutcli-1.2.tar.gz
| Download URL | nutcli-1.2.tar.gz |
|---|---|
| Size | 33.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec48e079bd887e8281b10c7de6de12b82101434b3d393cf26dac3a2e38b97d8f
|
|
BLAKE2b-256 checksum How to use checksums |
dfd8f08c65abc2f34ded756fef563396bc2287d3fc4040098dbfc5f4989d6f6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / nutcli-1.2-py3-none-any.whl
| Download URL | nutcli-1.2-py3-none-any.whl |
|---|---|
| Size | 36.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6df72677c0d2a30873ee3937202224d8a7fd73df41e7e30c115a87a922aefcb0
|
|
BLAKE2b-256 checksum How to use checksums |
dec0e5f6c30c5b2c7ed8c9331932cdac2ad88c80ec1ea32687aa4c68332a09f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for nutcli 1.2
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.