cleek 0.0.1__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.
Binary file
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ width="210mm"
6
+ height="297mm"
7
+ viewBox="0 0 210 297"
8
+ version="1.1"
9
+ id="svg1"
10
+ xml:space="preserve"
11
+ inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
12
+ sodipodi:docname="logo.svg"
13
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
14
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
17
+ id="namedview1"
18
+ pagecolor="#ffffff"
19
+ bordercolor="#666666"
20
+ borderopacity="1.0"
21
+ inkscape:showpageshadow="2"
22
+ inkscape:pageopacity="0.0"
23
+ inkscape:pagecheckerboard="0"
24
+ inkscape:deskcolor="#d1d1d1"
25
+ inkscape:document-units="mm"
26
+ inkscape:zoom="1.0670983"
27
+ inkscape:cx="326.58658"
28
+ inkscape:cy="450.28652"
29
+ inkscape:window-width="1920"
30
+ inkscape:window-height="1058"
31
+ inkscape:window-x="0"
32
+ inkscape:window-y="0"
33
+ inkscape:window-maximized="1"
34
+ inkscape:current-layer="layer1" /><defs
35
+ id="defs1" /><g
36
+ inkscape:label="Layer 1"
37
+ inkscape:groupmode="layer"
38
+ id="layer1"><path
39
+ style="fill:#d7d7d7;fill-opacity:1;stroke:#000000;stroke-width:2.64583;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
40
+ d="m 123.97327,107.1129 0.99178,74.38396 c -3.0629,24.49044 -11.44979,26.0363 -25.042598,26.28234 -13.4025,0.24258 -24.392025,-5.24806 -24.794653,-37.19199 l 9.174022,10.16581 c 0,0 0.141924,-6.88564 -0.743839,-10.16581 -1.100184,-4.07422 -2.885793,-8.10873 -5.557527,-11.37546 -2.676083,-3.27204 -10.063105,-7.71642 -10.063105,-7.71642 1.423901,37.71876 3.651485,65.47669 31.737151,63.97021 21.043929,-4.4e-4 31.303259,-15.49944 32.215429,-34.2944 0,0 1.9822,-48.1468 -1.22727,-73.90783 0,0 8.42379,-7.01297 9.51737,-9.079066 3.2554,-6.150409 -1.1452,-15.817931 -4.66328,-16.902904 -3.96153,-1.221735 -12.74815,-1.67797 -15.99148,0.904124 -2.57668,2.05136 -4.37578,9.902469 -4.20264,13.191448 0.89178,5.545348 5.51085,7.250588 8.65064,11.735988 z"
41
+ id="path1"
42
+ sodipodi:nodetypes="ccsccsscsccssssc" /><circle
43
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
44
+ id="path2"
45
+ cx="128.33102"
46
+ cy="93.26609"
47
+ r="6.1297264" /></g></svg>
cleek-0.0.1/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /*.egg-info/
2
+ /build/
3
+ /venv/
cleek-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Peter Sutton
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.
cleek-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,363 @@
1
+ Metadata-Version: 2.4
2
+ Name: cleek
3
+ Version: 0.0.1
4
+ Summary: A simple task runner that generates command line interfaces
5
+ Author-email: Peter Sutton <peter@foxdogstudio.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Framework :: Trio
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.13
18
+ Requires-Dist: rich
19
+ Requires-Dist: trio
20
+ Description-Content-Type: text/markdown
21
+
22
+ <p align=center><img src=".github/logo.png" /></p>
23
+
24
+ <p align=center><b>A simple task runner that generates command line interfaces</b></p>
25
+
26
+ ```Python
27
+ from cleek import task
28
+
29
+ @task
30
+ def binary_op(x: int, y: int, op: Literal['add', 'sub'] = 'add') -> None:
31
+ print(x, op, y)
32
+ ```
33
+
34
+ <p align=center><b>⬇️ Becomes ⬇️</b></p>
35
+
36
+ ```ShellSession
37
+ $ clk binary-op -h
38
+ usage: clk binary-op [-h] [-o {add,sub}] x y
39
+
40
+ positional arguments:
41
+ x
42
+ y
43
+
44
+ options:
45
+ -h, --help show this help message and exit
46
+ -o, --op {add,sub} default: add
47
+ ```
48
+
49
+ ## Install
50
+
51
+ ```ShellSession
52
+ $ git clone https://github.com/petersuttondev/cleek.git
53
+ $ pip install ./cleek
54
+ ```
55
+
56
+ ## Get Started
57
+
58
+ 1. Create a `cleeks.py` file in the root of your project and add tasks
59
+
60
+ ```Python
61
+ from cleek import task
62
+
63
+ @task
64
+ def greet(name: str) -> None:
65
+ print(f'Hello, {name}!')
66
+ ```
67
+
68
+ 2. Run `clk` from anywhere inside your project to see your tasks.
69
+
70
+ ```ShellSession
71
+ $ clk
72
+ ┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
73
+ ┃ Task ┃ Usage ┃
74
+ ┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
75
+ │ greet │ clk greet [-h] name │
76
+ └───────┴─────────────────────┘
77
+ ```
78
+
79
+ 3. Run `clk <task> -h` to print a task's help.
80
+
81
+ ```ShellSession
82
+ $ clk greet
83
+ usage: clk greet [-h] name
84
+
85
+ positional arguments:
86
+ name
87
+
88
+ options:
89
+ -h, --help show this help message and exit
90
+ ```
91
+
92
+ Finally, run a task:
93
+
94
+ ```ShellSession
95
+ $ clk greet Peter
96
+ Hello, Peter!
97
+ ```
98
+
99
+ ## Customizing Tasks
100
+
101
+ * Set a task's name:
102
+
103
+ ```Python
104
+ from cleek import task
105
+
106
+ @task('bar')
107
+ def foo() -> None:
108
+ print('foo function, bar task')
109
+ ```
110
+
111
+ ```ShellSession
112
+ $ clk bar
113
+ foo function, bar task
114
+ ```
115
+
116
+ * Set a task's group:
117
+
118
+ ```Python
119
+ from cleek import task
120
+
121
+ @task(group='foo')
122
+ def bar() -> None:
123
+ print('bar task in the foo group')
124
+ ```
125
+
126
+ ```ShellSession
127
+ $ clk foo.bar
128
+ bar task in the foo group
129
+ ```
130
+
131
+ * Set a task's style. Used when listing tasks. See [Rich's Style
132
+ documentation](https://rich.readthedocs.io/en/stable/style.html) for supported
133
+ styles.
134
+
135
+ ```Python
136
+ from cleek import task
137
+
138
+ @task(style='red')
139
+ def foo() -> None:
140
+ print("I'll be red if you run clk")
141
+ ```
142
+
143
+ * To apply the same customization to many tasks, use `customize()` to create a
144
+ pre-configured version of the `task` decorator.
145
+
146
+ ```Python
147
+ from cleek import customize
148
+
149
+ foo_task = customize('foo', style='red')
150
+
151
+ @foo_task
152
+ def a() -> None: ...
153
+
154
+ @foo_task
155
+ def b() -> None: ...
156
+
157
+ bar_task = customize('bar', style='blue')
158
+
159
+ @bar_task
160
+ def c() -> None: ...
161
+
162
+ @bar_task
163
+ def d() -> None: ...
164
+ ```
165
+
166
+ ```ShellSession
167
+ $ clk
168
+ ┏━━━━━━━┳━━━━━━━━━━━━━━━━┓
169
+ ┃ Task ┃ Usage ┃
170
+ ┡━━━━━━━╇━━━━━━━━━━━━━━━━┩
171
+ │ foo.a │ clk foo.a [-h] │
172
+ │ foo.b │ clk foo.b [-h] │
173
+ │ bar.c │ clk bar.c [-h] │
174
+ │ bar.d │ clk bar.d [-h] │
175
+ └───────┴────────────────┘
176
+ ```
177
+
178
+ ## Async Support
179
+
180
+ Your tasks can be `async` functions:
181
+
182
+ ```Python
183
+ from cleek import task
184
+ import trio
185
+
186
+ @task
187
+ async def sleep(duration: float = 1.0) -> None:
188
+ print(f'Sleeping for {duration} seconds')
189
+ await trio.sleep(duration)
190
+ ```
191
+
192
+ At the moment, `trio` is the only supported event loop. If want to use another
193
+ event loop (I'm guessing `asyncio`), open an issue and I'll add it.
194
+
195
+ ## Finding Tasks
196
+
197
+ 1. If the environmental variable `CLEEKS_PATH` is set, `clk` treats the value
198
+ as a path and attempts to load it. If the load fails, `clk` fails.
199
+
200
+ 2. `clk` searches upwards from the current working directory towards the root
201
+ directory `/`, looking for a `cleeks.py` script or a `cleeks` package. A
202
+ script takes precedence over a package if both are found in the same
203
+ directory.
204
+
205
+ ## Supported Parameters
206
+
207
+ If you get an error saying your task's parameters are not supported, open an
208
+ issue containing the function signature and I'll add support.
209
+
210
+ ### `bool`
211
+
212
+ * Keyword `bool` with `False` or `True` default
213
+
214
+ ```Python
215
+ def foo(a: bool = False): ...
216
+ def foo(a: bool = True): ...
217
+ ```
218
+
219
+ * Keyword optional `bool` with `False`, `True`, or `None` default
220
+
221
+ ```Python
222
+ def foo(a: bool | None = False): ...
223
+ def foo(a: bool | None = True): ...
224
+ def foo(a: bool | None = None): ...
225
+ ```
226
+
227
+ ### `str`
228
+
229
+ * Positional `str`
230
+
231
+ ```Python
232
+ def foo(a: str): ...
233
+ ```
234
+
235
+ * Positional optional `str`
236
+
237
+ ```Python
238
+ def foo(a: str | None): ...
239
+ ```
240
+
241
+ * Keyword `str` with `str` default
242
+
243
+ ```Python
244
+ def foo(a: str = 'a'): ...
245
+ ```
246
+
247
+ * Keyword optional `str` with `str` or `None` default
248
+
249
+ ```Python
250
+ def foo(a: str | None = 'a'): ...
251
+ def foo(a: str | None = None): ...
252
+ ```
253
+
254
+ * Variadic positional `str`
255
+
256
+ ```Python
257
+ def foo(*a: str): ...
258
+ ```
259
+
260
+ ### `int`
261
+
262
+ * Positional `int`
263
+
264
+ ```Python
265
+ def foo(a: int): ...
266
+ ```
267
+
268
+ * Keyword `int` with `int` default
269
+
270
+ ```Python
271
+ def foo(a: int = 1): ...
272
+ ```
273
+
274
+ * Keyword optional `int` with `int` or `None` default
275
+
276
+ ```Python
277
+ def foo(a: int | None = 1): ...
278
+ def foo(a: int | None = None): ...
279
+ ```
280
+
281
+ ### `float`
282
+
283
+ * Positional `float`
284
+
285
+ ```Python
286
+ def foo(a: float): ...
287
+ ```
288
+
289
+ * Keyword `float` with `float` default
290
+
291
+ ```Python
292
+ def foo(a: float = 1.0): ...
293
+ ```
294
+
295
+ * Keyword optional `float` with `float` or `None` default
296
+
297
+ ```Python
298
+ def foo(a: float | None = 1.0): ...
299
+ def foo(a: float | None = None): ...
300
+ ```
301
+
302
+ ### `Literal[T]`
303
+
304
+ * Positional `int` literal
305
+
306
+ ```Python
307
+ @task
308
+ def foo(a: Literal[1, 2, 3]): ...
309
+ ```
310
+
311
+ * Positional `str` literal
312
+
313
+ ```Python
314
+ @task
315
+ def foo(a: Literal['a', 'b', 'c']): ...
316
+ ```
317
+
318
+ * Keyword `int` literal with `int` default
319
+
320
+ ```Python
321
+ @task
322
+ def foo(a: Literal[1, 2, 3] = 1): ...
323
+ ```
324
+
325
+ * Keyword `str` literal with `str` default
326
+
327
+ ```Python
328
+ @task
329
+ def foo(a: Literal['a', 'b', 'c'] = 'a'): ...
330
+ ```
331
+
332
+ ### Misc
333
+
334
+ * Variadic positional `pathlib.Path`
335
+
336
+ ```Python
337
+ from pathlib import Path
338
+
339
+ @task
340
+ def foo(*a: Path): ...
341
+ ```
342
+
343
+ * Variadic positional `trio.Path`
344
+
345
+ ```Python
346
+ from trio import Path
347
+
348
+ @task
349
+ def foo(*a: Path): ...
350
+ ```
351
+
352
+ ## Shell Completion
353
+
354
+ `clk --completion` prints all task names to stdout.
355
+
356
+ ### zsh
357
+
358
+ ```Shell
359
+ _complete_clk() {
360
+ reply=($(clk --completion))
361
+ }
362
+
363
+ compctl -K _complete_clk + -f clk