cli-root-yo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,210 @@
1
+ # Dynamic version file (generated by setuptools_scm)
2
+ cli_root_yo/_version.py
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[codz]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py.cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # UV
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ #uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ #poetry.lock
112
+ #poetry.toml
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118
+ #pdm.lock
119
+ #pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # pixi
124
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125
+ #pixi.lock
126
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127
+ # in the .venv directory. It is recommended not to include this directory in version control.
128
+ .pixi
129
+
130
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131
+ __pypackages__/
132
+
133
+ # Celery stuff
134
+ celerybeat-schedule
135
+ celerybeat.pid
136
+
137
+ # SageMath parsed files
138
+ *.sage.py
139
+
140
+ # Environments
141
+ .env
142
+ .envrc
143
+ .venv
144
+ env/
145
+ venv/
146
+ ENV/
147
+ env.bak/
148
+ venv.bak/
149
+
150
+ # Spyder project settings
151
+ .spyderproject
152
+ .spyproject
153
+
154
+ # Rope project settings
155
+ .ropeproject
156
+
157
+ # mkdocs documentation
158
+ /site
159
+
160
+ # mypy
161
+ .mypy_cache/
162
+ .dmypy.json
163
+ dmypy.json
164
+
165
+ # Pyre type checker
166
+ .pyre/
167
+
168
+ # pytype static type analyzer
169
+ .pytype/
170
+
171
+ # Cython debug symbols
172
+ cython_debug/
173
+
174
+ # PyCharm
175
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
176
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
177
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
178
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
179
+ #.idea/
180
+
181
+ # Abstra
182
+ # Abstra is an AI-powered process automation framework.
183
+ # Ignore directories containing user credentials, local state, and settings.
184
+ # Learn more at https://abstra.io/docs
185
+ .abstra/
186
+
187
+ # Visual Studio Code
188
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
189
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
190
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
191
+ # you could uncomment the following to ignore the entire vscode folder
192
+ # .vscode/
193
+
194
+ # Ruff stuff:
195
+ .ruff_cache/
196
+
197
+ # PyPI configuration file
198
+ .pypirc
199
+
200
+ # Cursor
201
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
202
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
203
+ # refer to https://docs.cursor.com/context/ignore-files
204
+ .cursorignore
205
+ .cursorindexingignore
206
+
207
+ # Marimo
208
+ marimo/_static/
209
+ marimo/_lsp/
210
+ __marimo__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daylily Informatics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include LICENSE
2
+ include README.md
3
+ include SPEC.md
4
+ recursive-include cli_root_yo py.typed
5
+ prune .ignore
6
+ prune tests
7
+
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: cli-root-yo
3
+ Version: 0.1.0
4
+ Summary: Reusable CLI kernel for building unified command-line interfaces with consistent behavior, output style, help, and extension semantics.
5
+ Author: Daylily Informatics
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Daylily-Informatics/cli-root-yo
8
+ Project-URL: Repository, https://github.com/Daylily-Informatics/cli-root-yo
9
+ Project-URL: Issues, https://github.com/Daylily-Informatics/cli-root-yo/issues
10
+ Keywords: cli,typer,rich,plugin,xdg,framework
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Classifier: Topic :: Utilities
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: typer<0.22.0,>=0.21.0
26
+ Requires-Dist: rich<15.0.0,>=14.0.0
27
+ Requires-Dist: click<9.0.0,>=8.3.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
31
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.0; extra == "dev"
33
+ Requires-Dist: build>=1.0; extra == "dev"
34
+ Requires-Dist: twine>=5.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # cli-root-yo
38
+
39
+ [![GitHub Release](https://img.shields.io/github/v/release/Daylily-Informatics/cli-root-yo?style=flat-square&label=release)](https://github.com/Daylily-Informatics/cli-root-yo/releases/latest)
40
+ [![GitHub Tag](https://img.shields.io/github/v/tag/Daylily-Informatics/cli-root-yo?style=flat-square&label=tag)](https://github.com/Daylily-Informatics/cli-root-yo/tags)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
42
+
43
+ Reusable CLI kernel for building unified command-line interfaces with consistent behavior, output style, help, and extension semantics. Built on [Typer](https://typer.tiangolo.com/) + [Rich](https://rich.readthedocs.io/).
44
+
45
+ ## What It Does
46
+
47
+ `cli-root-yo` provides the shared foundation that downstream CLI tools build on:
48
+
49
+ - **Root app factory** — `create_app()` builds a fully configured Typer app from a declarative spec
50
+ - **Built-in commands** — `version`, `info`, and optional `config`/`env` groups
51
+ - **Plugin system** — explicit callables + `cli_root_yo.plugins` entry-point discovery
52
+ - **XDG paths** — platform-aware config/data/state/cache directory resolution (macOS + Linux)
53
+ - **Output primitives** — `heading`, `success`, `warning`, `error`, `action`, `detail`, `bullet`, `emit_json`
54
+ - **Runtime context** — immutable singleton accessible to all commands during invocation
55
+ - **JSON mode** — `--json`/`-j` flag with deterministic output (indent=2, sorted keys, no ANSI)
56
+ - **NO_COLOR** — respects the [NO_COLOR](https://no-color.org/) convention
57
+ - **Debug mode** — `CLI_ROOT_YO_DEBUG=1` prints tracebacks to STDERR
58
+
59
+ ## Prerequisites
60
+
61
+ - Python 3.10+
62
+ - pip
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ pip install cli-root-yo
68
+ ```
69
+
70
+ For development:
71
+
72
+ ```bash
73
+ git clone https://github.com/Daylily-Informatics/cli-root-yo.git
74
+ cd cli-root-yo
75
+ pip install -e ".[dev]"
76
+ ```
77
+
78
+ ## Quick Start
79
+
80
+ ```python
81
+ from cli_root_yo.spec import CliSpec, XdgSpec
82
+ from cli_root_yo.app import run
83
+
84
+ spec = CliSpec(
85
+ prog_name="my-tool",
86
+ app_display_name="My Tool",
87
+ dist_name="my-tool",
88
+ root_help="A CLI built with cli-root-yo.",
89
+ xdg=XdgSpec(vendor="my-tool"),
90
+ )
91
+
92
+ exit_code = run(spec)
93
+ ```
94
+
95
+ This gives you `my-tool version`, `my-tool info`, `my-tool --help`, `--json` support, and all the standard behaviors out of the box.
96
+
97
+ ## Adding Commands via Plugin
98
+
99
+ ```python
100
+ # my_tool/plugin.py
101
+ def register(registry, spec):
102
+ registry.add_command(None, "greet", greet_cmd, help_text="Say hello.")
103
+
104
+ def greet_cmd():
105
+ from cli_root_yo import output
106
+ output.success("Hello, world!")
107
+ ```
108
+
109
+ Register it in your spec:
110
+
111
+ ```python
112
+ from cli_root_yo.spec import PluginSpec
113
+
114
+ spec = CliSpec(
115
+ ...,
116
+ plugins=PluginSpec(explicit=["my_tool.plugin.register"]),
117
+ )
118
+ ```
119
+
120
+ Or via entry points in `pyproject.toml`:
121
+
122
+ ```toml
123
+ [project.entry-points."cli_root_yo.plugins"]
124
+ my-tool = "my_tool.plugin:register"
125
+ ```
126
+
127
+ ## Config & Env Groups
128
+
129
+ Enable optional built-in command groups by providing specs:
130
+
131
+ ```python
132
+ from cli_root_yo.spec import ConfigSpec, EnvSpec
133
+
134
+ spec = CliSpec(
135
+ ...,
136
+ config=ConfigSpec(
137
+ primary_filename="config.json",
138
+ template_bytes=b'{"key": "value"}\n',
139
+ ),
140
+ env=EnvSpec(
141
+ env_dir_name=".venv",
142
+ activate_script_rel="bin/activate",
143
+ ),
144
+ )
145
+ ```
146
+
147
+ This adds `config path|init|show|validate|edit|reset` and `env status|activate|deactivate|reset`.
148
+
149
+ ## Public API
150
+
151
+ | Symbol | Module | Description |
152
+ |--------|--------|-------------|
153
+ | `create_app(spec)` | `cli_root_yo.app` | Build a Typer app from a CliSpec |
154
+ | `run(spec, argv)` | `cli_root_yo.app` | Execute CLI, return exit code (never calls `sys.exit()`) |
155
+ | `CommandRegistry` | `cli_root_yo.registry` | Register commands/groups with ordering and conflict detection |
156
+ | `get_context()` | `cli_root_yo.runtime` | Access the current invocation's RuntimeContext |
157
+ | `CliSpec`, `ConfigSpec`, `EnvSpec`, `PluginSpec`, `XdgSpec` | `cli_root_yo.spec` | Frozen dataclass specs |
158
+ | `output.*` | `cli_root_yo.output` | UX primitives + `emit_json()` |
159
+
160
+ ## Exit Codes
161
+
162
+ | Code | Meaning |
163
+ |------|---------|
164
+ | 0 | Success |
165
+ | 1 | Domain/runtime failure |
166
+ | 2 | Usage error (bad args, unknown command) |
167
+ | 130 | SIGINT |
168
+
169
+ ## Build / Test / Lint
170
+
171
+ ```bash
172
+ # Run tests
173
+ python -m pytest tests/ -v --cov=cli_root_yo
174
+
175
+ # Lint + format check
176
+ ruff check cli_root_yo tests
177
+ ruff format --check cli_root_yo tests
178
+
179
+ # Type check
180
+ mypy cli_root_yo --ignore-missing-imports
181
+
182
+ # Build distribution
183
+ python -m build
184
+ twine check dist/*
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,153 @@
1
+ # cli-root-yo
2
+
3
+ [![GitHub Release](https://img.shields.io/github/v/release/Daylily-Informatics/cli-root-yo?style=flat-square&label=release)](https://github.com/Daylily-Informatics/cli-root-yo/releases/latest)
4
+ [![GitHub Tag](https://img.shields.io/github/v/tag/Daylily-Informatics/cli-root-yo?style=flat-square&label=tag)](https://github.com/Daylily-Informatics/cli-root-yo/tags)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6
+
7
+ Reusable CLI kernel for building unified command-line interfaces with consistent behavior, output style, help, and extension semantics. Built on [Typer](https://typer.tiangolo.com/) + [Rich](https://rich.readthedocs.io/).
8
+
9
+ ## What It Does
10
+
11
+ `cli-root-yo` provides the shared foundation that downstream CLI tools build on:
12
+
13
+ - **Root app factory** — `create_app()` builds a fully configured Typer app from a declarative spec
14
+ - **Built-in commands** — `version`, `info`, and optional `config`/`env` groups
15
+ - **Plugin system** — explicit callables + `cli_root_yo.plugins` entry-point discovery
16
+ - **XDG paths** — platform-aware config/data/state/cache directory resolution (macOS + Linux)
17
+ - **Output primitives** — `heading`, `success`, `warning`, `error`, `action`, `detail`, `bullet`, `emit_json`
18
+ - **Runtime context** — immutable singleton accessible to all commands during invocation
19
+ - **JSON mode** — `--json`/`-j` flag with deterministic output (indent=2, sorted keys, no ANSI)
20
+ - **NO_COLOR** — respects the [NO_COLOR](https://no-color.org/) convention
21
+ - **Debug mode** — `CLI_ROOT_YO_DEBUG=1` prints tracebacks to STDERR
22
+
23
+ ## Prerequisites
24
+
25
+ - Python 3.10+
26
+ - pip
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install cli-root-yo
32
+ ```
33
+
34
+ For development:
35
+
36
+ ```bash
37
+ git clone https://github.com/Daylily-Informatics/cli-root-yo.git
38
+ cd cli-root-yo
39
+ pip install -e ".[dev]"
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```python
45
+ from cli_root_yo.spec import CliSpec, XdgSpec
46
+ from cli_root_yo.app import run
47
+
48
+ spec = CliSpec(
49
+ prog_name="my-tool",
50
+ app_display_name="My Tool",
51
+ dist_name="my-tool",
52
+ root_help="A CLI built with cli-root-yo.",
53
+ xdg=XdgSpec(vendor="my-tool"),
54
+ )
55
+
56
+ exit_code = run(spec)
57
+ ```
58
+
59
+ This gives you `my-tool version`, `my-tool info`, `my-tool --help`, `--json` support, and all the standard behaviors out of the box.
60
+
61
+ ## Adding Commands via Plugin
62
+
63
+ ```python
64
+ # my_tool/plugin.py
65
+ def register(registry, spec):
66
+ registry.add_command(None, "greet", greet_cmd, help_text="Say hello.")
67
+
68
+ def greet_cmd():
69
+ from cli_root_yo import output
70
+ output.success("Hello, world!")
71
+ ```
72
+
73
+ Register it in your spec:
74
+
75
+ ```python
76
+ from cli_root_yo.spec import PluginSpec
77
+
78
+ spec = CliSpec(
79
+ ...,
80
+ plugins=PluginSpec(explicit=["my_tool.plugin.register"]),
81
+ )
82
+ ```
83
+
84
+ Or via entry points in `pyproject.toml`:
85
+
86
+ ```toml
87
+ [project.entry-points."cli_root_yo.plugins"]
88
+ my-tool = "my_tool.plugin:register"
89
+ ```
90
+
91
+ ## Config & Env Groups
92
+
93
+ Enable optional built-in command groups by providing specs:
94
+
95
+ ```python
96
+ from cli_root_yo.spec import ConfigSpec, EnvSpec
97
+
98
+ spec = CliSpec(
99
+ ...,
100
+ config=ConfigSpec(
101
+ primary_filename="config.json",
102
+ template_bytes=b'{"key": "value"}\n',
103
+ ),
104
+ env=EnvSpec(
105
+ env_dir_name=".venv",
106
+ activate_script_rel="bin/activate",
107
+ ),
108
+ )
109
+ ```
110
+
111
+ This adds `config path|init|show|validate|edit|reset` and `env status|activate|deactivate|reset`.
112
+
113
+ ## Public API
114
+
115
+ | Symbol | Module | Description |
116
+ |--------|--------|-------------|
117
+ | `create_app(spec)` | `cli_root_yo.app` | Build a Typer app from a CliSpec |
118
+ | `run(spec, argv)` | `cli_root_yo.app` | Execute CLI, return exit code (never calls `sys.exit()`) |
119
+ | `CommandRegistry` | `cli_root_yo.registry` | Register commands/groups with ordering and conflict detection |
120
+ | `get_context()` | `cli_root_yo.runtime` | Access the current invocation's RuntimeContext |
121
+ | `CliSpec`, `ConfigSpec`, `EnvSpec`, `PluginSpec`, `XdgSpec` | `cli_root_yo.spec` | Frozen dataclass specs |
122
+ | `output.*` | `cli_root_yo.output` | UX primitives + `emit_json()` |
123
+
124
+ ## Exit Codes
125
+
126
+ | Code | Meaning |
127
+ |------|---------|
128
+ | 0 | Success |
129
+ | 1 | Domain/runtime failure |
130
+ | 2 | Usage error (bad args, unknown command) |
131
+ | 130 | SIGINT |
132
+
133
+ ## Build / Test / Lint
134
+
135
+ ```bash
136
+ # Run tests
137
+ python -m pytest tests/ -v --cov=cli_root_yo
138
+
139
+ # Lint + format check
140
+ ruff check cli_root_yo tests
141
+ ruff format --check cli_root_yo tests
142
+
143
+ # Type check
144
+ mypy cli_root_yo --ignore-missing-imports
145
+
146
+ # Build distribution
147
+ python -m build
148
+ twine check dist/*
149
+ ```
150
+
151
+ ## License
152
+
153
+ MIT — see [LICENSE](LICENSE).