toolrack-cli 0.1.0__py3-none-any.whl
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.
- toolrack/__init__.py +3 -0
- toolrack/__main__.py +4 -0
- toolrack/cli.py +946 -0
- toolrack/completion.py +351 -0
- toolrack/entrypoint.py +14 -0
- toolrack/runtime.py +178 -0
- toolrack_cli-0.1.0.dist-info/METADATA +201 -0
- toolrack_cli-0.1.0.dist-info/RECORD +12 -0
- toolrack_cli-0.1.0.dist-info/WHEEL +5 -0
- toolrack_cli-0.1.0.dist-info/entry_points.txt +2 -0
- toolrack_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- toolrack_cli-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: toolrack-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn a folder of small scripts plus YAML sidecars into one typed, completable CLI
|
|
5
|
+
Author: Jan Chimiak
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/anfit/toolrack
|
|
8
|
+
Project-URL: Template, https://github.com/anfit/toolrack-template
|
|
9
|
+
Keywords: cli,scripts,click,dispatcher,shell-completion
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: click>=8.1
|
|
22
|
+
Requires-Dist: pyyaml>=6.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# toolrack
|
|
28
|
+
|
|
29
|
+
`toolrack` is the dispatcher engine behind a user-owned scripts repository.
|
|
30
|
+
It reads a registry of script paths, loads YAML sidecars beside those scripts,
|
|
31
|
+
and builds a typed Click CLI at runtime.
|
|
32
|
+
|
|
33
|
+
If you want the starter repository that uses this engine, see
|
|
34
|
+
[`toolrack-template`](https://github.com/anfit/toolrack-template).
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
git clone https://github.com/anfit/toolrack-template my-tools
|
|
42
|
+
cd my-tools
|
|
43
|
+
python setup_toolrack.py # venv, installs toolrack-cli from PyPI, wrappers, PATH, completion
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The engine is published on PyPI as `toolrack-cli`; the command it installs is
|
|
47
|
+
`toolrack`. To work on the engine itself, clone this repo and pass
|
|
48
|
+
`--toolrack ../toolrack` to the setup script for an editable install.
|
|
49
|
+
|
|
50
|
+
Open a new shell, then add a script and its sidecar:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# scripts/hello/greet.py
|
|
54
|
+
import sys
|
|
55
|
+
print(f"Hello, {sys.argv[1]}!")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
# scripts/hello/greet.yml
|
|
60
|
+
description: Print a greeting.
|
|
61
|
+
args:
|
|
62
|
+
- name: name
|
|
63
|
+
positional: true
|
|
64
|
+
required: true
|
|
65
|
+
help: Who to greet.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
my-tools core register scripts/hello/greet.py
|
|
70
|
+
my-tools hello greet Alice # -> Hello, Alice!
|
|
71
|
+
my-tools hello <TAB> # completes commands, options and choices
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Why This Exists
|
|
75
|
+
|
|
76
|
+
AI has made it dramatically easier to write small, useful scripts. That is the
|
|
77
|
+
good news. The follow-up news is that once you have twenty of them, "somewhere
|
|
78
|
+
in a folder" stops being a system.
|
|
79
|
+
|
|
80
|
+
`toolrack` is for that moment.
|
|
81
|
+
|
|
82
|
+
The basic idea is simple:
|
|
83
|
+
|
|
84
|
+
- AI is very good at helping you produce small scripts quickly.
|
|
85
|
+
- A growing script library still needs structure, discoverability, and sane UX.
|
|
86
|
+
- AI also benefits from compartmentalization: small scripts with narrow scope
|
|
87
|
+
are easier to write, review, test, and replace.
|
|
88
|
+
- AI work is non-deterministic by nature, so every stable, tested, deterministic
|
|
89
|
+
thing you can hand off to automation is one less task balanced on your pet
|
|
90
|
+
clanker's back.
|
|
91
|
+
|
|
92
|
+
This project is not trying to turn your script repo into a framework empire. It
|
|
93
|
+
is trying to help your collection of tiny automations stay tidy, callable, and
|
|
94
|
+
pleasant to use after the novelty phase.
|
|
95
|
+
|
|
96
|
+
## Showcase
|
|
97
|
+
|
|
98
|
+
The intended flow looks like this:
|
|
99
|
+
|
|
100
|
+
1. Create a scripts repository with a clear layout.
|
|
101
|
+
There is a starter repo for that:
|
|
102
|
+
[`toolrack-template`](https://github.com/anfit/toolrack-template).
|
|
103
|
+
2. Add small scripts under folders that match their area of work:
|
|
104
|
+
`github/`, `jira/`, `db/`, `images/`, `deploy/`, and so on.
|
|
105
|
+
3. Put a sidecar next to each script so the command has typed arguments, help,
|
|
106
|
+
and completion.
|
|
107
|
+
4. Plug `toolrack` into that repo so the whole thing becomes one coherent CLI.
|
|
108
|
+
|
|
109
|
+
The result is one command on your `PATH`, available from PowerShell, Git Bash,
|
|
110
|
+
or Cygwin, with shared help and completion instead of a growing folklore of
|
|
111
|
+
"I think that one is in a repo called maybe-tools-old?"
|
|
112
|
+
|
|
113
|
+
Example:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
my-tools github list-prs --state open --limit 20
|
|
117
|
+
my-tools jira show ISSUE-123
|
|
118
|
+
my-tools db query --env prod --file scripts/db/slow_report.sql
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
That is the main payoff: when you want to make a new script, it is not trapped
|
|
122
|
+
in "that project you did two years ago". It lives next to two similar scripts
|
|
123
|
+
in the folder dedicated to that area, where both humans and models can find the
|
|
124
|
+
pattern immediately.
|
|
125
|
+
|
|
126
|
+
Which also makes the AI prompt much nicer:
|
|
127
|
+
|
|
128
|
+
> Hey AI, make me one like this, but mauve.
|
|
129
|
+
|
|
130
|
+
## Deployment Model
|
|
131
|
+
|
|
132
|
+
`toolrack` is meant to be installed into a scripts repository and launched
|
|
133
|
+
through a repo-local wrapper in `bin/`.
|
|
134
|
+
|
|
135
|
+
The wrapper is responsible for:
|
|
136
|
+
|
|
137
|
+
- choosing the visible command name
|
|
138
|
+
- setting `TOOLRACK_REPO_ROOT`
|
|
139
|
+
- setting `TOOLRACK_SCRIPTS_ROOT`
|
|
140
|
+
- setting `TOOLRACK_REGISTRY_FILE` or `TOOLRACK_REGISTRY_BASENAME`
|
|
141
|
+
- invoking `python -m toolrack` from the repo's virtualenv
|
|
142
|
+
|
|
143
|
+
Defaults:
|
|
144
|
+
|
|
145
|
+
- CLI name: inferred from the wrapper filename, else `toolrack`
|
|
146
|
+
- registry basename: `.toolrack`
|
|
147
|
+
- repo discovery also accepts legacy `.attic` during walk-up
|
|
148
|
+
|
|
149
|
+
## Core Commands
|
|
150
|
+
|
|
151
|
+
`toolrack` provides a small management surface under `core`:
|
|
152
|
+
|
|
153
|
+
- `core register <script_path>`: add one script to the registry
|
|
154
|
+
- `core auto-register`: scan `scripts/` for sidecar-backed scripts
|
|
155
|
+
- `core unregister <script_path>`: remove one script from the registry
|
|
156
|
+
- `core reregister`: validate every registered script and sidecar
|
|
157
|
+
- `core refresh-cache`: rebuild the cached command metadata next to `.toolrack`
|
|
158
|
+
- `core list`: show registry entries and sidecar status
|
|
159
|
+
- `core install-completion <shell>`: print shell completion source
|
|
160
|
+
|
|
161
|
+
## Scripts Repo Contract
|
|
162
|
+
|
|
163
|
+
A scripts repository normally contains:
|
|
164
|
+
|
|
165
|
+
- `scripts/`: runnable `.py`, `.sh`, `.bash`, or `.sql` files
|
|
166
|
+
- `.toolrack`: registry of enabled scripts
|
|
167
|
+
- `.toolrack.cache.json`: cached command metadata used for faster startup and completion
|
|
168
|
+
- `aliases.cfg`: optional group aliases, stored next to `.toolrack`
|
|
169
|
+
- `bin/`: wrappers that export the toolrack environment variables
|
|
170
|
+
|
|
171
|
+
`aliases.cfg` lets you shorten first-level or nested group paths without
|
|
172
|
+
renaming folders. For example:
|
|
173
|
+
|
|
174
|
+
```ini
|
|
175
|
+
[groups]
|
|
176
|
+
environments = env
|
|
177
|
+
refactoring = refactor
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
That turns `your-tools environments get-status` into `your-tools env get-status`.
|
|
181
|
+
|
|
182
|
+
Sidecars live next to scripts as `<script>.yml`. See
|
|
183
|
+
[SIDECAR_SPEC.md](SIDECAR_SPEC.md).
|
|
184
|
+
|
|
185
|
+
For a starter repository layout, use
|
|
186
|
+
[`toolrack-template`](https://github.com/anfit/toolrack-template).
|
|
187
|
+
|
|
188
|
+
## Shell completion
|
|
189
|
+
|
|
190
|
+
Completion is answered from `.toolrack.cache.json` without importing Click, so
|
|
191
|
+
<TAB> stays fast; anything the fast path does not model exactly falls back to
|
|
192
|
+
Click. `core install-completion bash` prints a script that calls the Python
|
|
193
|
+
interpreter directly and falls back to the wrapper if that interpreter moves.
|
|
194
|
+
|
|
195
|
+
## Development
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
python -m pip install -e ".[dev]"
|
|
199
|
+
python -m pytest
|
|
200
|
+
python -m pytest -m integration -s
|
|
201
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
toolrack/__init__.py,sha256=gjqPceIPB7VSFPev-EHO2L4vPqW84IrdBSOArn4Nq-E,94
|
|
2
|
+
toolrack/__main__.py,sha256=c37inCl-LENkL3woa83_NG79cv-mWmnfn55o5IAyBn4,89
|
|
3
|
+
toolrack/cli.py,sha256=hEeVCsmbJIE1nE27RE6GBYPKWcO71__SEOuOufAwOyc,31883
|
|
4
|
+
toolrack/completion.py,sha256=zJzACXPi0S6-bYARDANEo9UGW711sImRlcX_loB6kgA,12296
|
|
5
|
+
toolrack/entrypoint.py,sha256=EJb56KQP5fuiREen-CVHOhcClC5iNeZqbe4OHtFK58o,296
|
|
6
|
+
toolrack/runtime.py,sha256=rvgkj6mPAb5dWAN-9NGnXk4vNGNoU4zCstM3LwpTDXc,6182
|
|
7
|
+
toolrack_cli-0.1.0.dist-info/licenses/LICENSE,sha256=HY3ZcN-SJ0Ev4wQyI9ULxOGHZiyPabaYWTM1yXF1Ov4,1068
|
|
8
|
+
toolrack_cli-0.1.0.dist-info/METADATA,sha256=RkDlom2_TY-jM0Tv490iQ1PZmLH-_VOCPa9wdp2LYh8,6857
|
|
9
|
+
toolrack_cli-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
10
|
+
toolrack_cli-0.1.0.dist-info/entry_points.txt,sha256=_kYSduYA1pVXFzdvJFiSGO0Dz96OMH6whzYLeiGOekM,54
|
|
11
|
+
toolrack_cli-0.1.0.dist-info/top_level.txt,sha256=FW1_1V4wV2ywBUpjvmjOK_5KeVXnVRmwWoKfGV7HQvw,9
|
|
12
|
+
toolrack_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jan Chimiak
|
|
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 @@
|
|
|
1
|
+
toolrack
|