Extension of `argparse` to provide fast and customizable argument parsing.
Project description
slap.core.cli
Extension of argparse
to provide fast and customizable argument parsing.
Usage
import argparse
from typing import Any, Optional
from slap.core.cli import CliApp, Command
class HelloCommand(Command):
def init_parser(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument("name")
def execute(self, args: Any) -> Optional[int]:
print(f"Hello, {args.name}!")
app = CliApp("minimal", "0.1.0")
app.add_command("hello", HelloCommand())
app.run()
Gives you the following CLI:
$ python examples/minimal.py
usage: minimal [-h] [-v] [--version] [{hello}] ...
positional arguments:
{hello} The subcommand to execute.
... Arguments for the subcommand.
options:
-h, --help show this help message and exit
-v, --verbose Increase the verbosity level.
--version show program's version number and exit
subcommands:
hello
Compatibility
Requires Python 3.6 or higher.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
slap.core.cli-0.1.3.tar.gz
(6.3 kB
view details)
Built Distribution
File details
Details for the file slap.core.cli-0.1.3.tar.gz
.
File metadata
- Download URL: slap.core.cli-0.1.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 176533ead59c4cf7c9130e382b42ba93c128487058825fb560fde02621a4901d |
|
MD5 | 610e72ea523f373347e4c98f1055f8de |
|
BLAKE2b-256 | fb76675eff9b24fc967181139dbefc3bc4897a1d739ce0dbe67f7dd384fdd475 |
File details
Details for the file slap.core.cli-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: slap.core.cli-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44b094be731c1077bd20d773118e7e955045a24620b51dff6e5b6d3e7e8911c6 |
|
MD5 | 21b0d76e22dbb7c2010dda22fb1b19b3 |
|
BLAKE2b-256 | 2597eb4d4c3c60c806fc17cae4d4ac89f42da987a6ee4be45ae5e91607460e64 |