{"id":14064986,"url":"https://github.com/jsphpl/python-cli-app","last_synced_at":"2025-12-30T17:26:46.209Z","repository":{"id":62562585,"uuid":"155990861","full_name":"jsphpl/python-cli-app","owner":"jsphpl","description":"Framework for creating CLI apps using Python","archived":false,"fork":false,"pushed_at":"2020-05-29T09:34:37.000Z","size":6,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-22T14:58:35.202Z","etag":null,"topics":["cli","framework","python","python-cli","python3"],"latest_commit_sha":null,"homepage":null,"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/jsphpl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-03T14:29:17.000Z","updated_at":"2024-11-13T12:07:05.000Z","dependencies_parsed_at":"2022-11-03T15:30:38.175Z","dependency_job_id":null,"html_url":"https://github.com/jsphpl/python-cli-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsphpl%2Fpython-cli-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsphpl%2Fpython-cli-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsphpl%2Fpython-cli-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsphpl%2Fpython-cli-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsphpl","download_url":"https://codeload.github.com/jsphpl/python-cli-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228045940,"owners_count":17861061,"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":["cli","framework","python","python-cli","python3"],"created_at":"2024-08-13T07:04:13.239Z","updated_at":"2025-12-30T17:26:46.171Z","avatar_url":"https://github.com/jsphpl.png","language":"Python","readme":"# Python CLI App\n\u003e Framework for creating CLI apps using Python\n\nThe purpose of this library is to speed up bulding CLI applications by providing abstract classes representing an app and its commands. It uses `argparse` to define and parse command line arguments.\n\n## Concepts\n### App\nAn \"App\" is the main entry point of an application. It groups together one or more commands\n\n### Command\nA \"Command\" is a single operation that the application can perform. It is identified by a positional argument on the command line. Let's take `git` as an example. `git` would be the **app** that provides different **commands**, such as `add`, `commit`, `merge`, `checkout`, etc.\n\n## Example\n**git.py**\n```python\n#!/usr/bin/env python3\n\nfrom cli_app import App\nfrom commands.checkout import Checkout\nfrom commands.merge import Merge\n\n\nclass Git(App):\n    \"\"\"Git - fast, scalable, distributed revision control system\"\"\"\n\n    def register_commands(self):\n        self.add_command('checkout', Checkout)  # make the Checkout command available through `git.py checkout …`\n        self.add_command('merge', Merge)  # make the Merge command available through `git.py merge …`\n\n\nif __name__ == '__main__':\n    app = Git()\n    app.run()\n\n```\n\n**commands/checkout.py**\n```python\nfrom cli_app import Command\n\n\nclass Checkout(Command):\n    \"\"\"Switch branches or restore working tree files\"\"\"\n\n    @staticmethod\n    def register_arguments(parser):\n        parser.add_argument('ref', type=str, help='The ref (branch name, tag, commit sha) to checkout')\n\n    def run(self):\n        # Do whatever needs to be done to checkout given ref\n        print('Checking out %s' % self.app.args.ref)\n```\n\n**commands/merge.py**\n```python\nfrom cli_app import Command\n\n\nclass Merge(Command):\n    \"\"\"Join two or more development histories together\"\"\"\n\n    @staticmethod\n    def register_arguments(parser):\n        parser.add_argument('branch', type=str, help='The branch to merge into the currently checked-out branch')\n\n    def run(self):\n        # Do whatever needs to be done to merge given branch\n        print('Merging %s into current branch' % self.app.args.branch)\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsphpl%2Fpython-cli-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsphpl%2Fpython-cli-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsphpl%2Fpython-cli-app/lists"}