{"id":13501334,"url":"https://github.com/BstLabs/py-dynacli","last_synced_at":"2025-03-29T08:32:25.621Z","repository":{"id":39860226,"uuid":"445495836","full_name":"BstLabs/py-dynacli","owner":"BstLabs","description":"DynaCLI is a cloud-friendly Python library for converting pure Python functions into Linux Shell commands.","archived":false,"fork":false,"pushed_at":"2023-02-17T11:39:33.000Z","size":1360,"stargazers_count":98,"open_issues_count":19,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-31T20:39:42.965Z","etag":null,"topics":["command-line-tool","linux-shell","python"],"latest_commit_sha":null,"homepage":"https://bstlabs.github.io/py-dynacli/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BstLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-01-07T11:18:54.000Z","updated_at":"2024-06-30T04:36:00.000Z","dependencies_parsed_at":"2024-01-15T13:35:53.166Z","dependency_job_id":null,"html_url":"https://github.com/BstLabs/py-dynacli","commit_stats":{"total_commits":61,"total_committers":8,"mean_commits":7.625,"dds":0.5737704918032787,"last_synced_commit":"082e5e4425b1de92afe8b9c10b8d6401c0feedee"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BstLabs%2Fpy-dynacli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BstLabs%2Fpy-dynacli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BstLabs%2Fpy-dynacli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BstLabs%2Fpy-dynacli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BstLabs","download_url":"https://codeload.github.com/BstLabs/py-dynacli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162092,"owners_count":20733351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","linux-shell","python"],"created_at":"2024-07-31T22:01:33.723Z","updated_at":"2025-03-29T08:32:22.953Z","avatar_url":"https://github.com/BstLabs.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# DynaCLI\n[![Downloads](https://static.pepy.tech/personalized-badge/dynacli?period=total\u0026units=none\u0026left_color=blue\u0026right_color=orange\u0026left_text=Downloads)](https://pepy.tech/project/dynacli)\n[![](https://img.shields.io/pypi/v/dynacli?label=PyPi)](https://pypi.org/project/dynacli/)\n[![](https://img.shields.io/github/license/BstLabs/py-dynacli?color=blue\u0026label=License)](https://github.com/BstLabs/py-dynacli/blob/main/LICENSE.md)\n\nDynaCLI (Dynamic CLI) is a cloud-friendly Python library for converting pure Python functions into Linux Shell commands on the fly.\n\nIt's ideal for automating routine development and administrative tasks in a modern cloud software environment because it supports converting a virtually unlimited set of functions into Shell commands with minimal run-time and maintenance overhead.\n\nUnlike other existing solutions such as [Click](https://click.palletsprojects.com/en/8.0.x/) and [Typer](https://typer.tiangolo.com/), there is no need for any function decorators. Further, unlike with all existing solutions, including those built on top of standard [argparse](https://docs.python.org/3/library/argparse.html), DynaCLI does not build all command parsers upfront, but rather builds dynamically a single command parser based on the command line inputs. When combined with the [Python Cloud Importer](https://asher-sterkin.medium.com/serverless-cloud-import-system-760d3c4a60b9) solution, DynaCLI becomes truly _open_ with regard to a practically unlimited set of commands, all coming directly from cloud storage. This, in turn, eliminates any need for periodic updates on client workstations.\n\nAt its core, DynaCLI is a Python package structure interpreter which makes any public function executable from the command line.\n\nDynaCLI was developed by BST LABS as an open source generic infrastructure foundation for the cloud version of Python run-time within the scope of the [Cloud AI Operating System (CAIOS)](http://caios.io) project.\n\nFor details about the DynaCLI rationale and design considerations, refer to [DynaCLI Github Pages](https://bstlabs.github.io/py-dynacli/).\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install DynaCLI from the PyPi site:\n\n```bash\npip3 install dynacli\n```\n\n## Usage\n\n## Define command line interpreter entry point\n\nYou can use `dynacli init \u003cCLI name\u003e path=\u003cactual path\u003e` command for bootstrapping the entry point file:\n\n```bash\n$ cd tutorials/greetings\n\n$ dynacli init say path=.\nSuccessfully created CLI entrypoint say at /home/ssm-user/OSS/py-dynacli/tutorials/greetings\n```\n\nThe created `say` file has some comments to change accordingly:\n\n```python\n#!/usr/bin/env python3\n\n\"\"\"\nDynaCLI bootstrap script # Change me\n\"\"\"\n\n\nimport os\nimport sys\nfrom typing import Final\n\nfrom dynacli import main\n\ncwd = os.path.dirname(os.path.realpath(__file__))\n\n__version__: Final[str] = \"0.0.0\" # Change me to define your own version\n\n\nsearch_path = [cwd] # Change me if you have different path; you can add multiple search pathes\nsys.path.extend(search_path)\n# root_packages = ['cli.dev', 'cli.admin'] # Change me if you have predefined root package name\n# main(search_path, root_packages) # Uncomment if you have root_packages defined\n\nmain(search_path)\n\n```\n\nLet's change it:\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nGreetings CLI\n\"\"\"\n\nimport sys\nimport os\nfrom typing import Final\n\nfrom dynacli import main\n\ncwd = os.path.dirname(os.path.realpath(__file__))\n\n__version__: Final[str] = \"1.0\"\n\nsearch_path = [cwd]\nsys.path.extend(search_path)\n\nmain(search_path)\n```\n\nThat is it, now we have ready to go CLI.\n\n## Define commands\n\nEvery public function in your search path will be treated as a command. For example,\n\n```python\ndef hello(*names: str) -\u003e None:\n    \"\"\"\n    Print Hello \u003cfirst-name\u003e \u003clast-name\u003e message\n    \n    Args:\n        names (str): variable list of names to be included in greeting\n        \n    Return: None\n    \"\"\"\n    print(f\"Hello, {' '.join(names)}\")\n```\n\n## Start using CLI\n\nLet's get the help message:\n\n```bash\n$ ./say -h\nusage: say [-h] [-v] {hello} ...\n\nGreetings CLI\n\npositional arguments:\n  {hello}\n    hello        Print Hello \u003cfirst-name\u003e \u003clast-name\u003e message\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -v, --version  show program's version number and exit\n```\n\nWe can get the version as easy as:\n\n```bash\n$ ./say --version\nsay - v1.0\n```\n\nNow the help about actual command:\n\n```bash\n$ ./say hello -h\nusage: say hello [-h] [names ...]\n\npositional arguments:\n  names       variable list of names to be included in greeting\n\noptional arguments:\n  -h, --help  show this help message and exit\n```\n\nFinally we can run the actual command(the hello function in fact) as:\n\n```bash\n$ ./say hello Shako Rzayev Asher Sterkin\nHello, Shako Rzayev Asher Sterkin\n```\n\nGo to [tutorials/greetings](tutorials/greetings) folder and try it yourself.\n\n## Read the full documentation\n\n[DynaCLI Github Pages](https://bstlabs.github.io/py-dynacli/)\n\n\n## License\n\nMIT License, Copyright (c) 2021-2022 BST LABS. See [LICENSE](LICENSE.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBstLabs%2Fpy-dynacli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBstLabs%2Fpy-dynacli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBstLabs%2Fpy-dynacli/lists"}