argumentor is a simple and lightweight library to build complex command-line tools.
https://pyargumentor.camelia.dev
- Python 99%
- Just 0.6%
- Shell 0.3%
- HTML 0.1%
|
All checks were successful
Testing / test (pull_request) Successful in 10s
Testing / lint (pull_request) Successful in 20s
Testing / test-build (pull_request) Successful in 9s
Testing / test (push) Successful in 10s
Testing / lint (push) Successful in 20s
Testing / test-build (push) Successful in 9s
Publish / check-version (release) Successful in 8s
Deploy / deploy (release) Successful in 41s
Publish / build (release) Successful in 12s
Publish / publish (release) Successful in 10s
|
||
|---|---|---|
| .forgejo | ||
| docs | ||
| src/argumentor | ||
| templates | ||
| tests | ||
| .gitignore | ||
| .mailmap | ||
| .pylintrc | ||
| CHANGELOG.md | ||
| checkver.sh | ||
| justfile | ||
| LICENSE | ||
| mkdocs.yml | ||
| pyproject.toml | ||
| README.md | ||
| setup.cfg | ||
argumentor
argumentor is a simple and lightweight library to build complex command-line tools.
Features
- Differenciate commands from options
- Define aliases for commands and options
- Automatically generate help pages
- Set default values
- No external dependencies
Installation
Using pip
The argumentor library can be installed from the Python Package Index (PyPI):
$ pip install argumentor
Installing from source
Using pip, it is also possible to install a package directly from source.
First clone the source code repository hosted on Codeberg:
$ git clone https://codeberg.org/camelia/python-argumentor argumentor
Then, enter the local repository and install argumentor (you may want to use a virtual environment):
$ cd argumentor
$ pip install .
Usage
Below is a minimalist code snippet that aims to demonstrate some basic uses of argumentor:
import sys
from argumentor import Argumentor
from argumentor.exc import ParsingError
argm = Argumentor("program-name")
argm.register_command(
"cmd1",
description="command 1",
)
argm.register_command(
"cmd2",
description="command 2",
)
argm.register_option(
"--opt",
"-o",
description="global option 1",
)
try:
cmd, opts = argm.parse()
except ParsingError as err:
print(err)
sys.exit(1)
More information about usage can be found in the documentation.
License
argumentor is free software! You are free to use, copy, modify, share and redistribute it under the terms of the GNU Lesser General Public License, version 3 or later.
