Human friendly CLI builder
Project description
Human friendly CLI builder.
Installation
pip install manage.py
Quickstart
cat manage.py
from manager import Manager
manager = Manager()
@manager.command
def echo(text, capitalyze=False):
"""print the given <name>"""
if capitalyze:
text = text.upper()
return text
if __name__ == '__main__':
manager.main()
manage --help:
usage: manage [<namespace>.]<command> [<args>] positional arguments: command the command to run optional arguments: -h, --help show this help message and exit available commands: echo print the given <name>
manage echo --help:
$ manage echo --help usage: manage [-h] [--capitalyze] text print the given <name> positional arguments: text no description optional arguments: -h, --help show this help message and exit --capitalyze no description
Managers
Managers can be used together by merging them
from third_party import manager
my_app_manager.merge(manager)
# Merge within a new namespace:
my_app_manager.merge(manager, namespace='third_party')
Commands
Commands can be organized within namespaces
@manager.command(namespace='config')
def set(key, value):
# ...
Arguments
Argument definition can be overridden
@manager.arg('first_arg', help='this is help for first arg')
@manager.command
def my_command(first_arg):
# ...
Environment
Environment variables can be sourced from a .env file as key=value pair.
Environment variable can be enforce using Manager.env decorator
@manager.env('MY_ENV_VAR')
@manager.command
def my_command():
return os.environ['MY_ENV_VAR']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
manage.py-0.1.2.tar.gz
(5.2 kB
view details)
File details
Details for the file manage.py-0.1.2.tar.gz
.
File metadata
- Download URL: manage.py-0.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4226acb29dc32bb0e692007022863bd1e38d34fc17401baadb9af21e17d6f422 |
|
MD5 | 99f8868f7a600cc77349aeb2e2c60b3d |
|
BLAKE2b-256 | ef6835b9ab95d3ac4708c25ea996f362f1917dbb066b432d310a071174878bdb |