arbutus
Simplification of CLI construction in Python based on argparse: just add branches and arguments. CLI construction from yaml file also available.
If you are interested in participating, please feel free to contribute.
Explore the docs »
Report Bug
Request Feature
Contents
Getting Started
Requirements
- Python 3.8 or above
- argparse
- logging
Installation
pip install arbutus
Usage
Once installed, the cli can be defined using a yaml file, using the keywords branches to define new branch names and arguments to define new arguments and it's characteristics. For example:
main:
branches:
sum:
arguments:
integers:
type: float
nargs: +
help: list of integers to sum
action:
name: sum_
source: sample
store:
arguments:
something:
type: str
nargs: +
help: string or strings to store
action: store
The yaml above would imply that a module named sample includes the action sum_, and makes use of the store action.
These actions can be defined using the @Arbutus.new_action wrapper. For example:
from arbutus import Arbutus
@Arbutus.new_action
def sum_(*args, **kwargs):
total = 0
for number in kwargs['values']:
total += number
print(total)
Finally, the CLI itself can be constructed by calling the from_yaml method:
import arbutus
if __name__ == '__main__':
cli = arbutus.Arbutus()
cli.from_yaml('sample/cli.yaml')
cli.parse_args()
The CLI can then be called like:
# This would display general help about the CLI functionality
python3 sample/sample.py -h
# This would display general help about the sum test functionality
python3 sample/sample.py sum -h
# This would throw the result of running the sum function with the passed arguments
python3 sample/sample.py sum 12 25 3
Roadmap
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Alvaro U. Bravo - alvaroubravo@gmail.com
Project Links:
Metadata
Release files for arbutus 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| arbutus-0.0.4.tar.gz | 14.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arbutus-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.2 kB
Release files / arbutus-0.0.4.tar.gz
| Download URL | arbutus-0.0.4.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bf4d09348116639a12d45a3445fdc1a1fb61c4fbb4d4f7bc2c3f631a2321961
|
|
BLAKE2b-256 checksum How to use checksums |
8c887d1bc581a6fa73f2b9265c9cdc7cac7a4fc38811657c88a654e0608a2187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Release files / arbutus-0.0.4-py3-none-any.whl
| Download URL | arbutus-0.0.4-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60b6f6550fe1f4230a5a78b5ea7bd66de9fe9266fccdbdf3f17cdbfc05f489e0
|
|
BLAKE2b-256 checksum How to use checksums |
3e6b9337f08f65f16d58db3943712d2e6bfd5a35333800b981d3344d94cd345a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for arbutus 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.