Build powerful command-line applications in Python ๐โก
- ๐ Documentation
- ๐ก Examples
- ๐ฅ๏ธ Source Code
- โ Simple & Advanced API
- โ Type Hints
- โ Easy to test
- โ Well documented
poetry add powercli-python
uv add powercli-python
Add powercli
dependencies = [
"powercli-python"
]
Commands and arguments are highly configurable yet provide good defaults to work well out of the box.
import sys
from powercli import Command
cmd = Command(
# Windows-style flag prefixes
prefix_short=None,
prefix_long="/",
# use other stream
file=sys.stderr,
)
Arguments are classes which can be instantiated dynamically and are not directly bound to a parser class.
from pathlib import Path
from powercli import Flag
cmd = Command()
flag = Flag(
short="f",
values=[("PATH", Path)],
)
cmd.add_arg(flag)
# ... or use the shorthand ...
cmd.flag(
short="f",
values=[("PATH", Path)]
)
$ python3 -m powerdoc path/to/file.py --man
$ python3 -m powerdoc path/to/file.py --man | groff -T utf8 -man
The built-in provided flags and commands make use of colored output respecting the user's preference.