{"id":20179495,"url":"https://github.com/csdummi/cli_framework","last_synced_at":"2026-06-09T10:31:51.695Z","repository":{"id":62562637,"uuid":"188096044","full_name":"CSDUMMI/cli_framework","owner":"CSDUMMI","description":"A Framework to make it easier for myself to develop small cli apps","archived":false,"fork":false,"pushed_at":"2019-06-12T15:43:18.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T04:48:16.055Z","etag":null,"topics":["app","cli","python","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CSDUMMI.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":"2019-05-22T18:51:09.000Z","updated_at":"2023-02-13T18:58:53.000Z","dependencies_parsed_at":"2022-11-03T15:30:40.437Z","dependency_job_id":null,"html_url":"https://github.com/CSDUMMI/cli_framework","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/CSDUMMI%2Fcli_framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSDUMMI%2Fcli_framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSDUMMI%2Fcli_framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CSDUMMI%2Fcli_framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CSDUMMI","download_url":"https://codeload.github.com/CSDUMMI/cli_framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241616681,"owners_count":19991542,"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":["app","cli","python","python3"],"created_at":"2024-11-14T02:26:55.693Z","updated_at":"2026-06-09T10:31:51.689Z","avatar_url":"https://github.com/CSDUMMI.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"**This is documentation refering to [this Repository](https://github.com/CSDUMMI/cli_framework)**\n# cli_framework\nA Framework to make it easier for myself to develop small cli apps\n\n# Install\nThis project can be installed using\npip:\n```bash\npip3 install CLI-csdummi\n```\n\n# An example implementation\nTo implement your own CLI app\nwith this library you have to import the\nclass CLI like this:\n```python\nfrom CLI.CLI import CLI\n```\n\nThen you define a class that inherits\nfrom `CLI` and define `__init__` like this:\n\n```python\nclass App(CLI):\n  def __init__(self):\n    super().__init__('app.json','add','remove','list')\n```\nThe `__init__` Function from `CLI` takes one positional\nargument `file` or in this case `'app.json'`.\nThis is the file where the variable `self.state`\nis loaded from and saved to before and after execution.\nYou can thus modify `self.state` like any `dict` and\nthen it will be saved afterwards.\nThe other arguments are the names of methods\nyou want to be accessed from the command-line.\nThese names must be members of the class `App` in this case.\nThis means you now have to implement these functions:\n```python\n  def add(self,args):\n    name = args[0]\n    balance = args[1]\n    self.state[name] = balance\n\n  def remove(self,args):\n    name = args[0]\n    del self.state[name]\n\n  def list(self,*args):\n    for i in self.state.keys():\n      print(\"Name: {}\\nBalance: {}\".format(i,self.state[i]))\n```\nAs you can see the names of the methods and the arguments in\n`__init__`.\n\nYou can now use your CLI App like this:\n```bash\n$ python3 App.py add \u003cname\u003e \u003cbalance\u003e\n$ python3 App.py remove \u003cname\u003e\n$ python3 App.py list\n$ python3 App.py help\n$ python3 App.py\n```\nYou can execute these commands right now,\nall code here was written in the file `App.py` in this Repository.\n\n### `help` == `''`\nIf there is no command, the `help` function, that was inherited from `CLI`\nis executed, it prints the docstring of `self`: `self.__doc__`.\nIf you want usage information for your CLI App to appear,\nyou just write the usage or help into the docstring like this:\n```python\nclass App(CLI):\n  \"\"\"\n  Usage:\n  add \u003cname\u003e \u003cbalance\u003e\\t:Add new user\n  remove \u003cname\u003e\\t:Remove user\n  list:\\tList all current users\n  help:\\tDisplay this help\n  \"\"\"\n  ...\n```\nThen you can use execute the CLI with this:\n```python\nif __name__ == '__main__':\n  app = App() # Create Instance of CLI App\n  app.run() # Execute Commandline Parsing\n```\nI hope this helped you and you can implement your own CL Apps or interfaces\nsoon.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsdummi%2Fcli_framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsdummi%2Fcli_framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsdummi%2Fcli_framework/lists"}