{"id":13638100,"url":"https://github.com/anki-code/xonsh-awesome-cli-app","last_synced_at":"2025-10-28T03:31:55.418Z","repository":{"id":228467806,"uuid":"764681567","full_name":"anki-code/xonsh-awesome-cli-app","owner":"anki-code","description":"Example of awesome CLI app template for xonsh.","archived":false,"fork":false,"pushed_at":"2024-03-28T09:37:24.000Z","size":71,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-23T07:02:02.164Z","etag":null,"topics":["awesome","awesome-tools","cli-app","console","python-cli","python-click","terminal-app","xonsh","xonsh-dev","xontrib"],"latest_commit_sha":null,"homepage":"","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/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"custom":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"]}},"created_at":"2024-02-28T14:22:00.000Z","updated_at":"2024-03-02T08:51:06.000Z","dependencies_parsed_at":"2024-03-19T00:09:24.528Z","dependency_job_id":"ddc7c48e-5cdb-4dc3-8104-0d96c1c15b77","html_url":"https://github.com/anki-code/xonsh-awesome-cli-app","commit_stats":null,"previous_names":["anki-code/xonsh-awesome-cli-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-awesome-cli-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-awesome-cli-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-awesome-cli-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-awesome-cli-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/xonsh-awesome-cli-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238574745,"owners_count":19494725,"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":["awesome","awesome-tools","cli-app","console","python-cli","python-click","terminal-app","xonsh","xonsh-dev","xontrib"],"created_at":"2024-08-02T01:00:40.245Z","updated_at":"2025-10-28T03:31:55.413Z","avatar_url":"https://github.com/anki-code.png","language":"Python","funding_links":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"],"categories":["Education materials"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e  \n    Example of awesome CLI app template for xonsh. Just fork it and add your commands.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e  \nIf you like the idea of bar theme click ⭐ on the repo and \u003ca href=\"https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!\u0026url=https://github.com/anki-code/xonsh-awesome-cli-app\" target=\"_blank\"\u003etweet\u003c/a\u003e.\n\u003c/p\u003e\n\n\n## Features\n\n* CLI: based on power and sugar from [click](https://click.palletsprojects.com).\n* Execution: pip-installable as well as clone-and-run.\n* Ability to grow your library.\n* Ability to set up context and environment.\n* Ability to set up context options and command arguments.\n* Ability to use environment variables as replacement of options and arguments.\n* Subgroups support e.g. `mycli subgroup subcommand --subcommand-option`.\n* Logging\n* Tests: local, docker.\n\n## Install\n\n```xsh\npip install git+https://github.com/anki-code/xonsh-awesome-cli-app\nmycli\n```\nor\n```xsh\ngit clone https://github.com/anki-code/xonsh-awesome-cli-app\ncd xonsh-awesome-cli-app\n./mycli\n```\n## Usage\n\nYou can use this app as a template to your own apps.\n\n```xsh\nmycli\n# Usage: mycli [OPTIONS] COMMAND [ARGS]...\n# \n#   CLI management.\n# \n# Options:\n#   --name TEXT  Context option: name.\n#   --debug      Context option: debug mode.\n#   --help       Show this message and exit.\n# \n# Commands:\n#  say      Say.\n#  context  Show app context.\n\nmycli hello --help\n# Usage: mycli hello [OPTIONS]\n# \n#   Say hello.\n# \n# Options:\n#   --wait  Command argument: wait before print.\n#   --help  Show this message and exit.\n\nmycli say hello\n# Username say: hello\n\nmycli say hello --wait\n# Wait...\n# Username say: hello\n\nmycli --name Mike say hello --wait\n# Wait...\n# Mike say: hello\n\n$MYCLI_NAME = 'Alex'\nmycli say hello\n# Alex say: hello\n\nmycli context\n# Environment:\n# {'MYCLI_NAME': 'Alex'}\n# Context:\n# {'debug': False, 'log': \u003cRootLogger root (INFO)\u003e, 'name': 'Alex'}\n\nmycli --debug say hello\n# TRACE SUBPROC: (['echo', 'Username', 'say:', 'hello'],), captured=hiddenobject\n# Username say: hello\n# 2024-03-01 18:21:24,723 - root - INFO - Additional log message.\n# TRACE SUBPROC: (['echo', 'Here', 'is', 'debug', 'message', 'too', ''],), captured=hiddenobject\n# Here is debug message too\n```\n\n### How to create subcommands\n\nIf you need subcommands (subgroups) e.g.:\n\n```xsh\nmycli env activate --name myname\nmycli env deactivate\nmycli info --full\n```\n\nuse this example:\n\n```python\nimport click\n\n@click.group()  # Create main group in `click`\ndef cli():\n    pass\n\n@cli.group()  # Create subgroup `env` in `cli`\ndef env():\n    pass\n\n@env.command()  # Create subcommand `activate` in `env`\n@click.option('--name')\ndef activate(name):\n    click.echo(f\"Activating environment: {name}\")\n```\n\n## Tests\n\nYou can use `pytest` for test cli:\n\n```xsh\npytest tests/\n# tests/test_app.xsh passed\n```\n\n## Known issues\n\n### pytest: xonsh not found\n\nIn some sort situations you need to use current env python to run tests:\n\n```xsh\n@(sys.executable) -m pytest -v\n```\n\n```xsh\nimport sys\npy = sys.executable\ndef test_help():\n    @(py) -m xonsh ./mycli --help\n```\n\n## See more CLI libs\n* [click](https://click.palletsprojects.com/), [Shared options and flags between commands](https://stackoverflow.com/questions/40182157/shared-options-and-flags-between-commands)\n* [rich](https://github.com/Textualize/rich)\n* [typer](https://typer.tiangolo.com/)\n\n## See also\n* [xonsh-cheatsheet](https://github.com/anki-code/xonsh-cheatsheet) - Cheat sheet for xonsh shell with copy-pastable examples. \n* [rc-awesome](https://github.com/anki-code/xontrib-rc-awesome) - Awesome snippets of code for xonshrc in xonsh shell.\n* [macro](https://github.com/anki-code/xontrib-macro) - Library of the useful macro for the xonsh shell.\n* [docker-xonsh-wrapper](https://github.com/anki-code/docker-xonsh-wrapper) - Wrap an app in docker container and catch the signals from docker using xonsh shell. \n* [xunter](https://github.com/anki-code/xunter) - Profiling the xonsh shell code using [hunter](https://github.com/ionelmc/python-hunter).\n* [Xxh Development Environment (xde)](https://github.com/xxh/xxh/tree/7222c47482a8e46cbdf1eb23589f40962425a4a0/xde)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxonsh-awesome-cli-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Fxonsh-awesome-cli-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxonsh-awesome-cli-app/lists"}