# decree-tree
The `decree-tree` package provides a lightweight means for defining
nested command-line interfaces, using standard `argparse`-based
parsing wrapped in a flexible class.
## Installation
To install ``decree-tree`` from PyPI via pip, run this shell command
with the proper Python environment active:
```shell
pip install decree-tree
```
If you are using a different package manager, such as Poetry,
use its appropriate installation command for the ``decree-tree``
package on PyPI.
## Usage
To create a command tree, subclass `decree_tree.DecreeTree` create
new commands, then assemble their instances appropriately. For
example, consider this file `command.py`:
```python
from decree_tree import DecreeTree
class Root(DecreeTree):
def add_arguments(self, parser):
super().add_arguments(parser)
parser.add_argument('-v', '--value')
class Echo(DecreeTree):
def execute(self):
super().execute()
print(self.options.value)
class Double(DecreeTree):
def execute(self):
super().execute()
print(self.options.value, self.options.value)
root = Root()
root.add(Echo)
root.add(Double)
if __name__ == '__main__':
root.run()
```
Invoking script above yields results like the following:
```shell
$ python command.py double -v bark
bark bark
```
This script can be called in many other ways, including
displaying autogenerated help. The behavior is very customizable.
## Documentation
See the full documentation [here](https://elasmocalc.net/decree-tree).
## Status
This package is relatively stable, and has had an initial release, but
is still under initial development.
To contribute, create an issue or submit an MR!
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/elasmocalc/decree-tree",
"name": "decree-tree",
"maintainer": "Jared Ahern",
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": "jared.ahern.dev@gmail.com",
"keywords": "command, cli",
"author": "Jared Ahern",
"author_email": "jared.ahern.dev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0d/d4/21c8718a4816f1a85bbba8675c5bb23ba4c493df221563f46bd4b2172156/decree_tree-0.2.0.tar.gz",
"platform": null,
"description": "# decree-tree\n\nThe `decree-tree` package provides a lightweight means for defining\nnested command-line interfaces, using standard `argparse`-based\nparsing wrapped in a flexible class.\n\n## Installation\n\nTo install ``decree-tree`` from PyPI via pip, run this shell command\nwith the proper Python environment active:\n\n```shell\npip install decree-tree\n```\n\nIf you are using a different package manager, such as Poetry,\nuse its appropriate installation command for the ``decree-tree``\npackage on PyPI.\n\n## Usage\n\nTo create a command tree, subclass `decree_tree.DecreeTree` create\nnew commands, then assemble their instances appropriately. For\nexample, consider this file `command.py`:\n\n```python\nfrom decree_tree import DecreeTree\n\nclass Root(DecreeTree):\n def add_arguments(self, parser):\n super().add_arguments(parser)\n parser.add_argument('-v', '--value')\n\nclass Echo(DecreeTree):\n def execute(self):\n super().execute()\n print(self.options.value)\n\nclass Double(DecreeTree):\n def execute(self):\n super().execute()\n print(self.options.value, self.options.value)\n\nroot = Root()\nroot.add(Echo)\nroot.add(Double)\n\nif __name__ == '__main__':\n root.run()\n```\n\nInvoking script above yields results like the following:\n\n```shell\n$ python command.py double -v bark\nbark bark\n```\n\nThis script can be called in many other ways, including\ndisplaying autogenerated help. The behavior is very customizable.\n\n## Documentation\n\nSee the full documentation [here](https://elasmocalc.net/decree-tree).\n\n## Status\n\nThis package is relatively stable, and has had an initial release, but\nis still under initial development.\n\nTo contribute, create an issue or submit an MR!\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A minimal way to create nested argparse-based subcommands in scripts.",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://elasmocalc.net/decree-tree",
"Homepage": "https://gitlab.com/elasmocalc/decree-tree",
"Repository": "https://gitlab.com/elasmocalc/decree-tree",
"issues": "https://gitlab.com/elasmocalc/decree-tree/issues",
"pypi": "https://pypi.org/project/decree-tree/"
},
"split_keywords": [
"command",
" cli"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24e320d6e3bebf2b99e47e6a3e6ce4457b94adb125eb22c820202dca357bfc1c",
"md5": "487fafdf9cb58e213ef18fb0b4ae7b01",
"sha256": "c71c1d6c8fea4d01527266a9997d3dd90cc9792c6972523fb71f603503ac6b1f"
},
"downloads": -1,
"filename": "decree_tree-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "487fafdf9cb58e213ef18fb0b4ae7b01",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 16896,
"upload_time": "2024-11-17T20:12:43",
"upload_time_iso_8601": "2024-11-17T20:12:43.136523Z",
"url": "https://files.pythonhosted.org/packages/24/e3/20d6e3bebf2b99e47e6a3e6ce4457b94adb125eb22c820202dca357bfc1c/decree_tree-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0dd421c8718a4816f1a85bbba8675c5bb23ba4c493df221563f46bd4b2172156",
"md5": "135993579a5615948fc80fb2e982770b",
"sha256": "ea241650ac4acb0e28f1c416979a43278ce02becc225d0e6f7f55fb4ba1a7e0f"
},
"downloads": -1,
"filename": "decree_tree-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "135993579a5615948fc80fb2e982770b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 15553,
"upload_time": "2024-11-17T20:12:45",
"upload_time_iso_8601": "2024-11-17T20:12:45.058529Z",
"url": "https://files.pythonhosted.org/packages/0d/d4/21c8718a4816f1a85bbba8675c5bb23ba4c493df221563f46bd4b2172156/decree_tree-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-17 20:12:45",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "elasmocalc",
"gitlab_project": "decree-tree",
"lcname": "decree-tree"
}