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 hashes)
Built Distribution
Close
Hashes for slap.core.cli-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44b094be731c1077bd20d773118e7e955045a24620b51dff6e5b6d3e7e8911c6 |
|
MD5 | 21b0d76e22dbb7c2010dda22fb1b19b3 |
|
BLAKE2b-256 | 2597eb4d4c3c60c806fc17cae4d4ac89f42da987a6ee4be45ae5e91607460e64 |