Metadata-Version: 2.1
Name: slap.core.cli
Version: 0.1.3
Summary: Extension of `argparse` to provide fast and customizable argument parsing.
License: MIT
Author: Niklas Rosenstein
Author-email: rosensteinniklas@gmail.com
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: termcolor (>=1.1.0,<2.0.0)
Project-URL: Bug Tracker, https://github.com/python-slap/slap.core.cli/issues
Project-URL: Repository, https://github.com/python-slap/slap.core.cli
Description-Content-Type: text/markdown

# slap.core.cli

Extension of [`argparse`][0] to provide fast and customizable argument parsing.

  [0]: https://docs.python.org/3/library/argparse.html

## Usage

```py
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.

