library to create a commandline application easily
Project description
PyCommandApp
library to create a commandline application easily
Index
Installation
python3 -m pip install commandapp
View on pypi.org
Usage
Code
from commandapp import CommandApp
app = CommandApp()
@app.register
def hello(name: str):
r"""
prints hello `name`
"""
print("Hello {}".format(name))
@app.register(name="print")
def cmd_print(text: str):
r"""
print what he should say
"""
print(text)
app.run()
Console
>> py myapp.py
usage: -c [-h] {hello,print} ...
>> py myapp.py -h
usage: -c [-h] {hello,print} ...
optional arguments:
-h, --help show this help message and exit
command:
{hello,print} available commands
hello prints hello `name`
print print what he should say
>> py myapp.py hello
usage: -c hello [-h] name
hello: error: the following arguments are required: name
>> py myapp.py hello "python"
Hello python
>> py myapp.py print "This package is awesome"
This package is awesome
Tips
Keyword-Parameter
Code
from commandapp import CommandApp
app = CommandApp()
@app.register
def a(param: str):
print([param])
@app.register
def b(*, param: str):
print([param])
app.run()
Console
>> py myapp.py a "Value"
["Value"]
>> py myapp.py b "Value"
b: error: the following arguments are required: --param
>> py myapp.py b --param "Value"
["Value"]
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
commandapp-0.2.1.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file commandapp-0.2.1.tar.gz
.
File metadata
- Download URL: commandapp-0.2.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c834da2ff02961bbd7af647dd2e50665f641ac873e04cfadeb5ec10484dbcef |
|
MD5 | c7f54329e09d25e1ba985c530a2146dc |
|
BLAKE2b-256 | ab21e557902825cf97d53d723a3693b6f8afd23fe40796fcb8994f38b259c62f |
File details
Details for the file commandapp-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: commandapp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f356872c76cba48fc1c018f66dd6b30e7cc336a5bfc61653516bb5521a0199d6 |
|
MD5 | 2e4e7803db6060fe0294d634cddeba69 |
|
BLAKE2b-256 | 261510728bbe7e71d1746494c30bb2c9864b3e24f780b7adb6943d49e14e5aa6 |