paramspecli 0.2.1__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.
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: paramspecli
3
+ Version: 0.2.1
4
+ Summary: Type-safe facade for the venerable argparse
5
+ Author: jkmnt
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ License-File: LICENSE
12
+ Project-URL: Documentation, https://jkmnt.github.io/paramspecli
13
+ Project-URL: Source, https://github.com/jkmnt/paramspecli
14
+
15
+ # paramspecli
16
+
17
+ **paramspecli** is a facade for the venerable [argparse](https://docs.python.org/3/library/argparse.html).
18
+ It's simple, composable, and fun. But, most important, it's type-safe thanks to the [ParamSpec](https://docs.python.org/3/library/typing.html#typing.ParamSpec) magic.
19
+
20
+ ## Quick start
21
+
22
+ ```python
23
+ from paramspecli import Command, argument, option, flag
24
+
25
+
26
+ def ping(addr: str, *, until_stopped: bool, count: int | None):
27
+ print(f"Pinging {addr} ...")
28
+
29
+
30
+ cli = Command(ping, prog="ping")
31
+ cli.bind(
32
+ -argument("IP"),
33
+ until_stopped=-flag("-t"),
34
+ count=-option("-n", type=int),
35
+ )
36
+
37
+ result = cli.parse()
38
+ result()
39
+ ```
40
+
41
+ Running it:
42
+
43
+ ```
44
+ $ python ping.py -t -n 10 127.0.0.1
45
+ Pinging 127.0.0.1 ...
46
+ ```
47
+
48
+ Type checker catches common errors:
49
+
50
+ ```python
51
+ cli.bind(
52
+ # "bool" is not assignable to "str"
53
+ -argument("IP", type=bool),
54
+ # Type "bool | None" is not assignable to type "bool"
55
+ until_stopped=-flag("-t", default=None),
56
+ #
57
+ # Argument missing for parameter "count"
58
+ )
59
+ ```
60
+
61
+ IDE suggestions work too:
62
+
63
+ <pre>
64
+ cli.bind(⏎
65
+ <small>(<strong>addr: str</strong>, *, until_stopped: bool, count: int | None) -> None</small>
66
+ </pre>
67
+
68
+ ## Installation
69
+
70
+ ```shell
71
+ pip install paramspecli
72
+ ```
73
+
74
+ ## Key points
75
+
76
+ **paramspecli** builds hierarchical CLIs with groups and commands.
77
+
78
+ - Commands match handler functions parameters with arguments and options.
79
+ - Arguments are bound to the handler's positional parameters.
80
+ - Options are bound to the handler's keyword parameters.
81
+ - Groups organize the commands. Groups may be nested. They could act like like an intermediate commands, i.e. have own handlers, options and arguments.
82
+ - CLI 'compiles' to the `argparse`, runs it, then outputs the parse result.
83
+ - Parse result is a callable. Calling it invokes handlers along the route.
84
+
85
+ **paramspecli** supports several advanced `argparse` features: help sections, mutually exclusive
86
+ options, options with the same destination. And adds a few own, like const options and passing contexts. It also includes a markdown documentation generator.
87
+
88
+ [Read the documentation](https://jkmnt.github.io/paramspecli)
@@ -0,0 +1,16 @@
1
+ paramspecli/__init__.py,sha256=etAehCcFInoM7XRh7-1QQfuq2ykL4anwDWhPVelnN6E,916
2
+ paramspecli/apstub.py,sha256=9mKHRUZk9K1zKPpdsYAhOdxgVQSwmuow6og_4EZ2tJ0,2641
3
+ paramspecli/args.py,sha256=Zypxg_JQiBsvC9oaijXNnvqtzRUZfR2D-RUpZGqrIbk,2442
4
+ paramspecli/cli.py,sha256=bT1Y94LdqpaIYAG09Tni1f0SehfCFojDDE6_6KUUTeQ,31439
5
+ paramspecli/conv.py,sha256=cTnL2LVyoy_5GAfEwlximA-hh_wX44NDXUykdWkm0yY,1959
6
+ paramspecli/doc.py,sha256=na3p4C8mUERnoMHCxyjxLGZy5KYRw2uhbIzOFyeRKVw,11466
7
+ paramspecli/fake.py,sha256=EiV825FY6gAor_NhLrPjeoUMzmVyXJH_3qDZp1AysFs,3400
8
+ paramspecli/flags.py,sha256=Q8GPWnmCOmJ0sTZ1j3b4TAz7fx5MK34Bk0Y0iu8pKK4,5017
9
+ paramspecli/md.py,sha256=jQEtQSTlagUKhTm3BCbl2bZeLDA30RLDl3c23EBwSHU,2125
10
+ paramspecli/opts.py,sha256=ArvCN6dw8EfBJ8ZjAUNpoo2qBrnIppKZQFioiZB8wwM,8429
11
+ paramspecli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ paramspecli/util.py,sha256=Byn68bnp97k6zK6H9KQRnheqwFMzZRdU3riig_W06d4,1382
13
+ paramspecli-0.2.1.dist-info/licenses/LICENSE,sha256=CEcG7lAfbHe2yVPoacsWX5dA0PtygQcuhHv6MqNI0PM,1062
14
+ paramspecli-0.2.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
15
+ paramspecli-0.2.1.dist-info/METADATA,sha256=mR00CyujFGja8EDCp7Z2ar91CIt9ti_g2uvXVyWzOgw,2594
16
+ paramspecli-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.12.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jkmnt
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.