{"id":18403712,"url":"https://github.com/russellluo/cmdr","last_synced_at":"2025-04-12T19:11:40.811Z","repository":{"id":30875976,"uuid":"34433635","full_name":"RussellLuo/cmdr","owner":"RussellLuo","description":"A command manager (i.e. Commander) for Python modules and packages.","archived":false,"fork":false,"pushed_at":"2015-05-03T13:19:13.000Z","size":156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T00:17:47.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RussellLuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-23T04:28:30.000Z","updated_at":"2015-05-03T13:19:14.000Z","dependencies_parsed_at":"2022-09-02T14:22:04.699Z","dependency_job_id":null,"html_url":"https://github.com/RussellLuo/cmdr","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/RussellLuo%2Fcmdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fcmdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fcmdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussellLuo%2Fcmdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RussellLuo","download_url":"https://codeload.github.com/RussellLuo/cmdr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618277,"owners_count":21134200,"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":[],"created_at":"2024-11-06T02:47:59.744Z","updated_at":"2025-04-12T19:11:40.791Z","avatar_url":"https://github.com/RussellLuo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Cmdr\n====\n\nA command manager (i.e. Commander) for Python modules and packages.\n\n\nInstallation\n------------\n\nInstall `Cmdr` with `pip`:\n\n    $ pip install Python-Cmdr\n\nInstall development version from `GitHub`:\n\n    $ git clone https://github.com/RussellLuo/cmdr.git\n    $ cd cmdr\n    $ python setup.py install\n\n\nWhy Cmdr?\n---------\n\nHow to execute commands written in Python? There are some typical (or popular) ways:\n\n1. Raw scripts\n\n        $ vi /tmp/demo/hello.py\n\n        def main():\n            print('hello')\n\n        if __name__ == '__main__':\n            main()\n\n        $ python /tmp/demo/hello.py\n\n2. Use [click][1]\n\n        $ vi /tmp/demo/hello.py\n\n        import click\n\n        @click.command()\n        def main():\n            print('hello')\n\n        if __name__ == '__main__':\n            main()\n\n        $ python /tmp/demo/hello.py\n\n\n3. Use [fabric][2]\n\n        $ vi /tmp/demo/hello.py\n\n        from fabric.api import task\n\n        @task\n        def main():\n            print('hello')\n\n        $ fab -f /tmp/demo/hello.py main\n\nAlthough `click` and `fabric` are awesome (and flexible), they are also invasive (your code must depend on them). And all of the methods above may be tedious if you want to **manage a lot of commands which are almost independent, through an uniform interface**.\n\nWhen you begin to care these problems, `Cmdr` is born for you.\n\n\nQuickstart\n----------\n\nWith `Cmdr`, we can just write normal Python modules or packages, and then use them as commands.\n\nTo make it happen, you must follow the steps below:\n\n1. Set the `COMMANDS_PATH` configuration in a YAML file\n\n        $ vi /tmp/demo/cmdr.yml\n\n        COMMANDS_PATH: /tmp/demo/commands\n\n2. Set the environment variable `CMDR_CONFIG_YAML`\n\n        $ export CMDR_CONFIG_YAML=/tmp/demo/cmdr.yml\n\n3. Create a Python module in `COMMANDS_PATH`\n\n        # Note here:\n        # the module \"hello.py\" is located in `COMMANDS_PATH`\n        # (i.e. \"/tmp/demo/commands\").\n\n        $ vi /tmp/demo/commands/hello.py\n\n        # A function named \"main\" is defined here,\n        # since the default `ENTRY_POINT` is \"main\".\n        # You can customize it by setting your preferred\n        # entry point name as `ENTRY_POINT` in the YAML file.\n\n        def main():\n            print('hello')\n\n4. Show available commands (identified by module/package names)\n\n        $ cmdr -l\n\n5. Execute the command `hello`\n\n        $ cmdr hello\n\n6. Add more Python modules or packages\n\n\nExample\n-------\n\nSee [here][3] for an example.\n\n\nLicense\n-------\n\n[MIT][4]\n\n\n[1]: https://github.com/mitsuhiko/click\n[2]: https://github.com/fabric/fabric\n[3]: https://github.com/RussellLuo/cmdr/tree/master/example\n[4]: http://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussellluo%2Fcmdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frussellluo%2Fcmdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussellluo%2Fcmdr/lists"}