cli-command-parser 2024.12.15__tar.gz → 2025.5.10__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.
- {cli_command_parser-2024.12.15/lib/cli_command_parser.egg-info → cli_command_parser-2025.5.10}/PKG-INFO +134 -130
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__version__.py +2 -2
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/choices.py +6 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/actions.py +2 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/testing.py +3 -4
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10/lib/cli_command_parser.egg-info}/PKG-INFO +134 -130
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/readme.rst +4 -1
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/setup.cfg +50 -50
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/LICENSE +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/MANIFEST.in +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/entry_points.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__init__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__main__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/annotations.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/command_parameters.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/commands.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/compat.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/config.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/context.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/__init__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/__main__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/argparse_ast.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/argparse_utils.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/cli.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/command_builder.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/utils.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/visitor.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/core.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/documentation.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/error_handling.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/exceptions.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/__init__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/commands.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/params.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/restructured_text.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/utils.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/__init__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/base.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/exceptions.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/files.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/numeric.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/patterns.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/time.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/utils.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/metadata.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/nargs.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/__init__.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/base.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/choice_map.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/groups.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/option_strings.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/options.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/pass_thru.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/positionals.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parse_tree.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parser.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/typing.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/utils.py +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/SOURCES.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/dependency_links.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/entry_points.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/requires.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/top_level.txt +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/pyproject.toml +0 -0
- {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/requirements-dev.txt +0 -0
|
@@ -1,130 +1,134 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: cli_command_parser
|
|
3
|
-
Version:
|
|
4
|
-
Summary: CLI Command Parser
|
|
5
|
-
Home-page: https://github.com/dskrypa/cli_command_parser
|
|
6
|
-
Author: Doug Skrypa
|
|
7
|
-
Author-email: dskrypa@gmail.com
|
|
8
|
-
License: Apache 2.0
|
|
9
|
-
Project-URL: Source, https://github.com/dskrypa/cli_command_parser
|
|
10
|
-
Project-URL: Documentation, https://dskrypa.github.io/cli_command_parser
|
|
11
|
-
Project-URL: Issues, https://github.com/dskrypa/cli_command_parser/issues
|
|
12
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
-
Classifier: Environment :: Console
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
-
Classifier: Operating System :: OS Independent
|
|
17
|
-
Classifier: Programming Language :: Python
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
-
Classifier: Topic :: Software Development :: User Interfaces
|
|
25
|
-
Classifier: Topic :: Text Processing
|
|
26
|
-
Requires-Python: >=3.9
|
|
27
|
-
Description-Content-Type: text/x-rst
|
|
28
|
-
License-File: LICENSE
|
|
29
|
-
Provides-Extra: wcwidth
|
|
30
|
-
Requires-Dist: wcwidth; extra == "wcwidth"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cli_command_parser
|
|
3
|
+
Version: 2025.5.10
|
|
4
|
+
Summary: CLI Command Parser
|
|
5
|
+
Home-page: https://github.com/dskrypa/cli_command_parser
|
|
6
|
+
Author: Doug Skrypa
|
|
7
|
+
Author-email: dskrypa@gmail.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Project-URL: Source, https://github.com/dskrypa/cli_command_parser
|
|
10
|
+
Project-URL: Documentation, https://dskrypa.github.io/cli_command_parser
|
|
11
|
+
Project-URL: Issues, https://github.com/dskrypa/cli_command_parser/issues
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
25
|
+
Classifier: Topic :: Text Processing
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/x-rst
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Provides-Extra: wcwidth
|
|
30
|
+
Requires-Dist: wcwidth; extra == "wcwidth"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
CLI Command Parser
|
|
34
|
+
##################
|
|
35
|
+
|
|
36
|
+
|downloads| |py_version| |coverage_badge| |build_status| |Ruff| |OpenSSF Best Practices|
|
|
37
|
+
|
|
38
|
+
.. |py_version| image:: https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20-blue
|
|
39
|
+
:target: https://pypi.org/project/cli-command-parser/
|
|
40
|
+
|
|
41
|
+
.. |coverage_badge| image:: https://codecov.io/gh/dskrypa/cli_command_parser/branch/main/graph/badge.svg
|
|
42
|
+
:target: https://codecov.io/gh/dskrypa/cli_command_parser
|
|
43
|
+
|
|
44
|
+
.. |build_status| image:: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml/badge.svg
|
|
45
|
+
:target: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml
|
|
46
|
+
|
|
47
|
+
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
48
|
+
:target: https://docs.astral.sh/ruff/
|
|
49
|
+
|
|
50
|
+
.. |downloads| image:: https://img.shields.io/pypi/dm/cli-command-parser
|
|
51
|
+
:target: https://pypistats.org/packages/cli-command-parser
|
|
52
|
+
|
|
53
|
+
.. |OpenSSF Best Practices| image:: https://www.bestpractices.dev/projects/9845/badge
|
|
54
|
+
:target: https://www.bestpractices.dev/projects/9845
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the
|
|
58
|
+
tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex
|
|
59
|
+
CLIs while remaining readable and easy to maintain.
|
|
60
|
+
|
|
61
|
+
The primary goals of this project:
|
|
62
|
+
- Make it easy to define subcommands and actions in an clean and organized manner
|
|
63
|
+
- Allow for inheritance so that common parameters don't need to be repeated
|
|
64
|
+
- Make it easy to handle common initialization tasks for all actions / subcommands once
|
|
65
|
+
- Reduce the amount of boilerplate code that is necessary for setting up parsing and handling argument values
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
Example Program
|
|
69
|
+
***************
|
|
70
|
+
|
|
71
|
+
.. code-block:: python
|
|
72
|
+
|
|
73
|
+
from cli_command_parser import Command, Option, main
|
|
74
|
+
|
|
75
|
+
class Hello(Command, description='Simple greeting example'):
|
|
76
|
+
name = Option('-n', default='World', help='The person to say hello to')
|
|
77
|
+
count: int = Option('-c', default=1, help='Number of times to repeat the message')
|
|
78
|
+
|
|
79
|
+
def main(self):
|
|
80
|
+
for _ in range(self.count):
|
|
81
|
+
print(f'Hello {self.name}!')
|
|
82
|
+
|
|
83
|
+
if __name__ == '__main__':
|
|
84
|
+
main()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
.. code-block:: shell-session
|
|
88
|
+
|
|
89
|
+
$ hello_world.py --name Bob -c 3
|
|
90
|
+
Hello Bob!
|
|
91
|
+
Hello Bob!
|
|
92
|
+
Hello Bob!
|
|
93
|
+
|
|
94
|
+
$ hello_world.py -h
|
|
95
|
+
usage: hello_world.py [--name NAME] [--count COUNT] [--help]
|
|
96
|
+
|
|
97
|
+
Simple greeting example
|
|
98
|
+
|
|
99
|
+
Optional arguments:
|
|
100
|
+
--name NAME, -n NAME The person to say hello to (default: 'World')
|
|
101
|
+
--count COUNT, -c COUNT Number of times to repeat the message (default: 1)
|
|
102
|
+
--help, -h Show this help message and exit
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
Installing CLI Command Parser
|
|
106
|
+
*****************************
|
|
107
|
+
|
|
108
|
+
CLI Command Parser can be installed and updated via `pip <https://pip.pypa.io/en/stable/getting-started/>`__::
|
|
109
|
+
|
|
110
|
+
$ pip install -U cli-command-parser
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
There are no required dependencies. Support for formatting wide characters correctly in help text descriptions can
|
|
114
|
+
be included by adding `wcwidth <https://wcwidth.readthedocs.io>`__ to your project's requirements, and/or by installing
|
|
115
|
+
with optional dependencies::
|
|
116
|
+
|
|
117
|
+
$ pip install -U cli-command-parser[wcwidth]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Python Version Compatibility
|
|
121
|
+
============================
|
|
122
|
+
|
|
123
|
+
Python versions 3.9 and above are currently supported. The last release of CLI Command Parser that supported 3.8 was
|
|
124
|
+
2024-09-07. Support for Python 3.8 `officially ended on 2024-10-07 <https://devguide.python.org/versions/>`__.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Links
|
|
128
|
+
*****
|
|
129
|
+
|
|
130
|
+
- Documentation: https://dskrypa.github.io/cli_command_parser/
|
|
131
|
+
- Example Scripts: https://github.com/dskrypa/cli_command_parser/tree/main/examples
|
|
132
|
+
- PyPI Releases: https://pypi.org/project/cli-command-parser/
|
|
133
|
+
- Source Code: https://github.com/dskrypa/cli_command_parser
|
|
134
|
+
- Issue Tracker: https://github.com/dskrypa/cli_command_parser/issues
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__version__.py
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
__title__ = 'cli_command_parser'
|
|
2
2
|
__description__ = 'CLI Command Parser'
|
|
3
3
|
__url__ = 'https://github.com/dskrypa/cli_command_parser'
|
|
4
|
-
__version__ = '
|
|
4
|
+
__version__ = '2025.05.10'
|
|
5
5
|
__author__ = 'Doug Skrypa'
|
|
6
6
|
__author_email__ = 'dskrypa@gmail.com'
|
|
7
7
|
__license__ = 'Apache 2.0'
|
|
8
|
-
__copyright__ = 'Copyright
|
|
8
|
+
__copyright__ = 'Copyright 2024 Doug Skrypa'
|
|
@@ -147,6 +147,12 @@ class ChoiceMap(Choices[T]):
|
|
|
147
147
|
|
|
148
148
|
return self._case_insensitive_map_choice(value)
|
|
149
149
|
|
|
150
|
+
def fix_default(self, value: Any) -> T:
|
|
151
|
+
if value in self.choices.values():
|
|
152
|
+
return value
|
|
153
|
+
else:
|
|
154
|
+
return self(value)
|
|
155
|
+
|
|
150
156
|
|
|
151
157
|
class EnumChoices(_ChoicesBase[EnumT]):
|
|
152
158
|
"""
|
|
@@ -145,6 +145,8 @@ class ParamAction(ABC):
|
|
|
145
145
|
return self.default
|
|
146
146
|
|
|
147
147
|
def finalize_default(self, value):
|
|
148
|
+
if self.param.strict_default:
|
|
149
|
+
return value
|
|
148
150
|
if (type_func := self.param.type) and isinstance(type_func, InputType):
|
|
149
151
|
return type_func.fix_default(value)
|
|
150
152
|
return value
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/testing.py
RENAMED
|
@@ -94,9 +94,6 @@ class ParserTest(TestCase):
|
|
|
94
94
|
def assert_dict_equal(self, d1, d2, msg: str = None):
|
|
95
95
|
self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
|
|
96
96
|
self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
|
|
97
|
-
self._assert_dict_equal(d1, d2, msg)
|
|
98
|
-
|
|
99
|
-
def _assert_dict_equal(self, d1, d2, msg: str = None):
|
|
100
97
|
if d1 != d2:
|
|
101
98
|
self.fail(self._formatMessage(msg, f'{d1} != {d2}\n{format_dict_diff(d1, d2)}'))
|
|
102
99
|
|
|
@@ -105,7 +102,9 @@ class ParserTest(TestCase):
|
|
|
105
102
|
|
|
106
103
|
def assert_parse_results(self, cmd_cls: CommandCls, argv: Argv, expected: Expected, msg: str = None) -> Command:
|
|
107
104
|
cmd = cmd_cls.parse(argv)
|
|
108
|
-
|
|
105
|
+
parsed = cmd.ctx.get_parsed(cmd, exclude=EXCLUDE_ACTIONS)
|
|
106
|
+
if expected != parsed:
|
|
107
|
+
self.fail(msg or f'Expected results ({expected}) != {parsed=}\n{format_dict_diff(expected, parsed)}')
|
|
109
108
|
return cmd
|
|
110
109
|
|
|
111
110
|
def assert_parse_results_cases(self, cmd_cls: CommandCls, cases: Iterable[Case], msg: str = None):
|
|
@@ -1,130 +1,134 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: cli_command_parser
|
|
3
|
-
Version:
|
|
4
|
-
Summary: CLI Command Parser
|
|
5
|
-
Home-page: https://github.com/dskrypa/cli_command_parser
|
|
6
|
-
Author: Doug Skrypa
|
|
7
|
-
Author-email: dskrypa@gmail.com
|
|
8
|
-
License: Apache 2.0
|
|
9
|
-
Project-URL: Source, https://github.com/dskrypa/cli_command_parser
|
|
10
|
-
Project-URL: Documentation, https://dskrypa.github.io/cli_command_parser
|
|
11
|
-
Project-URL: Issues, https://github.com/dskrypa/cli_command_parser/issues
|
|
12
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
-
Classifier: Environment :: Console
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
-
Classifier: Operating System :: OS Independent
|
|
17
|
-
Classifier: Programming Language :: Python
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
-
Classifier: Topic :: Software Development :: User Interfaces
|
|
25
|
-
Classifier: Topic :: Text Processing
|
|
26
|
-
Requires-Python: >=3.9
|
|
27
|
-
Description-Content-Type: text/x-rst
|
|
28
|
-
License-File: LICENSE
|
|
29
|
-
Provides-Extra: wcwidth
|
|
30
|
-
Requires-Dist: wcwidth; extra == "wcwidth"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cli_command_parser
|
|
3
|
+
Version: 2025.5.10
|
|
4
|
+
Summary: CLI Command Parser
|
|
5
|
+
Home-page: https://github.com/dskrypa/cli_command_parser
|
|
6
|
+
Author: Doug Skrypa
|
|
7
|
+
Author-email: dskrypa@gmail.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Project-URL: Source, https://github.com/dskrypa/cli_command_parser
|
|
10
|
+
Project-URL: Documentation, https://dskrypa.github.io/cli_command_parser
|
|
11
|
+
Project-URL: Issues, https://github.com/dskrypa/cli_command_parser/issues
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
25
|
+
Classifier: Topic :: Text Processing
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/x-rst
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Provides-Extra: wcwidth
|
|
30
|
+
Requires-Dist: wcwidth; extra == "wcwidth"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
CLI Command Parser
|
|
34
|
+
##################
|
|
35
|
+
|
|
36
|
+
|downloads| |py_version| |coverage_badge| |build_status| |Ruff| |OpenSSF Best Practices|
|
|
37
|
+
|
|
38
|
+
.. |py_version| image:: https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20-blue
|
|
39
|
+
:target: https://pypi.org/project/cli-command-parser/
|
|
40
|
+
|
|
41
|
+
.. |coverage_badge| image:: https://codecov.io/gh/dskrypa/cli_command_parser/branch/main/graph/badge.svg
|
|
42
|
+
:target: https://codecov.io/gh/dskrypa/cli_command_parser
|
|
43
|
+
|
|
44
|
+
.. |build_status| image:: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml/badge.svg
|
|
45
|
+
:target: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml
|
|
46
|
+
|
|
47
|
+
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
48
|
+
:target: https://docs.astral.sh/ruff/
|
|
49
|
+
|
|
50
|
+
.. |downloads| image:: https://img.shields.io/pypi/dm/cli-command-parser
|
|
51
|
+
:target: https://pypistats.org/packages/cli-command-parser
|
|
52
|
+
|
|
53
|
+
.. |OpenSSF Best Practices| image:: https://www.bestpractices.dev/projects/9845/badge
|
|
54
|
+
:target: https://www.bestpractices.dev/projects/9845
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the
|
|
58
|
+
tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex
|
|
59
|
+
CLIs while remaining readable and easy to maintain.
|
|
60
|
+
|
|
61
|
+
The primary goals of this project:
|
|
62
|
+
- Make it easy to define subcommands and actions in an clean and organized manner
|
|
63
|
+
- Allow for inheritance so that common parameters don't need to be repeated
|
|
64
|
+
- Make it easy to handle common initialization tasks for all actions / subcommands once
|
|
65
|
+
- Reduce the amount of boilerplate code that is necessary for setting up parsing and handling argument values
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
Example Program
|
|
69
|
+
***************
|
|
70
|
+
|
|
71
|
+
.. code-block:: python
|
|
72
|
+
|
|
73
|
+
from cli_command_parser import Command, Option, main
|
|
74
|
+
|
|
75
|
+
class Hello(Command, description='Simple greeting example'):
|
|
76
|
+
name = Option('-n', default='World', help='The person to say hello to')
|
|
77
|
+
count: int = Option('-c', default=1, help='Number of times to repeat the message')
|
|
78
|
+
|
|
79
|
+
def main(self):
|
|
80
|
+
for _ in range(self.count):
|
|
81
|
+
print(f'Hello {self.name}!')
|
|
82
|
+
|
|
83
|
+
if __name__ == '__main__':
|
|
84
|
+
main()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
.. code-block:: shell-session
|
|
88
|
+
|
|
89
|
+
$ hello_world.py --name Bob -c 3
|
|
90
|
+
Hello Bob!
|
|
91
|
+
Hello Bob!
|
|
92
|
+
Hello Bob!
|
|
93
|
+
|
|
94
|
+
$ hello_world.py -h
|
|
95
|
+
usage: hello_world.py [--name NAME] [--count COUNT] [--help]
|
|
96
|
+
|
|
97
|
+
Simple greeting example
|
|
98
|
+
|
|
99
|
+
Optional arguments:
|
|
100
|
+
--name NAME, -n NAME The person to say hello to (default: 'World')
|
|
101
|
+
--count COUNT, -c COUNT Number of times to repeat the message (default: 1)
|
|
102
|
+
--help, -h Show this help message and exit
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
Installing CLI Command Parser
|
|
106
|
+
*****************************
|
|
107
|
+
|
|
108
|
+
CLI Command Parser can be installed and updated via `pip <https://pip.pypa.io/en/stable/getting-started/>`__::
|
|
109
|
+
|
|
110
|
+
$ pip install -U cli-command-parser
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
There are no required dependencies. Support for formatting wide characters correctly in help text descriptions can
|
|
114
|
+
be included by adding `wcwidth <https://wcwidth.readthedocs.io>`__ to your project's requirements, and/or by installing
|
|
115
|
+
with optional dependencies::
|
|
116
|
+
|
|
117
|
+
$ pip install -U cli-command-parser[wcwidth]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Python Version Compatibility
|
|
121
|
+
============================
|
|
122
|
+
|
|
123
|
+
Python versions 3.9 and above are currently supported. The last release of CLI Command Parser that supported 3.8 was
|
|
124
|
+
2024-09-07. Support for Python 3.8 `officially ended on 2024-10-07 <https://devguide.python.org/versions/>`__.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Links
|
|
128
|
+
*****
|
|
129
|
+
|
|
130
|
+
- Documentation: https://dskrypa.github.io/cli_command_parser/
|
|
131
|
+
- Example Scripts: https://github.com/dskrypa/cli_command_parser/tree/main/examples
|
|
132
|
+
- PyPI Releases: https://pypi.org/project/cli-command-parser/
|
|
133
|
+
- Source Code: https://github.com/dskrypa/cli_command_parser
|
|
134
|
+
- Issue Tracker: https://github.com/dskrypa/cli_command_parser/issues
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
CLI Command Parser
|
|
2
2
|
##################
|
|
3
3
|
|
|
4
|
-
|downloads| |py_version| |coverage_badge| |build_status| |Ruff|
|
|
4
|
+
|downloads| |py_version| |coverage_badge| |build_status| |Ruff| |OpenSSF Best Practices|
|
|
5
5
|
|
|
6
6
|
.. |py_version| image:: https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20-blue
|
|
7
7
|
:target: https://pypi.org/project/cli-command-parser/
|
|
@@ -18,6 +18,9 @@ CLI Command Parser
|
|
|
18
18
|
.. |downloads| image:: https://img.shields.io/pypi/dm/cli-command-parser
|
|
19
19
|
:target: https://pypistats.org/packages/cli-command-parser
|
|
20
20
|
|
|
21
|
+
.. |OpenSSF Best Practices| image:: https://www.bestpractices.dev/projects/9845/badge
|
|
22
|
+
:target: https://www.bestpractices.dev/projects/9845
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the
|
|
23
26
|
tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
[metadata]
|
|
2
|
-
name = cli_command_parser
|
|
3
|
-
version = attr: cli_command_parser.__version__.__version__
|
|
4
|
-
description = CLI Command Parser
|
|
5
|
-
url = https://github.com/dskrypa/cli_command_parser
|
|
6
|
-
project_urls =
|
|
7
|
-
Source = https://github.com/dskrypa/cli_command_parser
|
|
8
|
-
Documentation = https://dskrypa.github.io/cli_command_parser
|
|
9
|
-
Issues = https://github.com/dskrypa/cli_command_parser/issues
|
|
10
|
-
license = Apache 2.0
|
|
11
|
-
license_files = LICENSE
|
|
12
|
-
long_description = file: readme.rst
|
|
13
|
-
long_description_content_type = text/x-rst
|
|
14
|
-
author = Doug Skrypa
|
|
15
|
-
author_email = dskrypa@gmail.com
|
|
16
|
-
classifiers =
|
|
17
|
-
Development Status :: 5 - Production/Stable
|
|
18
|
-
Environment :: Console
|
|
19
|
-
Intended Audience :: Developers
|
|
20
|
-
License :: OSI Approved :: Apache Software License
|
|
21
|
-
Operating System :: OS Independent
|
|
22
|
-
Programming Language :: Python
|
|
23
|
-
Programming Language :: Python :: 3
|
|
24
|
-
Programming Language :: Python :: 3.9
|
|
25
|
-
Programming Language :: Python :: 3.10
|
|
26
|
-
Programming Language :: Python :: 3.11
|
|
27
|
-
Programming Language :: Python :: 3.12
|
|
28
|
-
Programming Language :: Python :: 3.13
|
|
29
|
-
Topic :: Software Development :: User Interfaces
|
|
30
|
-
Topic :: Text Processing
|
|
31
|
-
|
|
32
|
-
[options]
|
|
33
|
-
include_package_data = True
|
|
34
|
-
entry_points = file: entry_points.txt
|
|
35
|
-
packages = find:
|
|
36
|
-
package_dir = = lib
|
|
37
|
-
python_requires = >=3.9
|
|
38
|
-
tests_require = testtools; coverage
|
|
39
|
-
|
|
40
|
-
[options.packages.find]
|
|
41
|
-
where = lib
|
|
42
|
-
|
|
43
|
-
[options.extras_require]
|
|
44
|
-
wcwidth =
|
|
45
|
-
wcwidth
|
|
46
|
-
|
|
47
|
-
[egg_info]
|
|
48
|
-
tag_build =
|
|
49
|
-
tag_date = 0
|
|
50
|
-
|
|
1
|
+
[metadata]
|
|
2
|
+
name = cli_command_parser
|
|
3
|
+
version = attr: cli_command_parser.__version__.__version__
|
|
4
|
+
description = CLI Command Parser
|
|
5
|
+
url = https://github.com/dskrypa/cli_command_parser
|
|
6
|
+
project_urls =
|
|
7
|
+
Source = https://github.com/dskrypa/cli_command_parser
|
|
8
|
+
Documentation = https://dskrypa.github.io/cli_command_parser
|
|
9
|
+
Issues = https://github.com/dskrypa/cli_command_parser/issues
|
|
10
|
+
license = Apache 2.0
|
|
11
|
+
license_files = LICENSE
|
|
12
|
+
long_description = file: readme.rst
|
|
13
|
+
long_description_content_type = text/x-rst
|
|
14
|
+
author = Doug Skrypa
|
|
15
|
+
author_email = dskrypa@gmail.com
|
|
16
|
+
classifiers =
|
|
17
|
+
Development Status :: 5 - Production/Stable
|
|
18
|
+
Environment :: Console
|
|
19
|
+
Intended Audience :: Developers
|
|
20
|
+
License :: OSI Approved :: Apache Software License
|
|
21
|
+
Operating System :: OS Independent
|
|
22
|
+
Programming Language :: Python
|
|
23
|
+
Programming Language :: Python :: 3
|
|
24
|
+
Programming Language :: Python :: 3.9
|
|
25
|
+
Programming Language :: Python :: 3.10
|
|
26
|
+
Programming Language :: Python :: 3.11
|
|
27
|
+
Programming Language :: Python :: 3.12
|
|
28
|
+
Programming Language :: Python :: 3.13
|
|
29
|
+
Topic :: Software Development :: User Interfaces
|
|
30
|
+
Topic :: Text Processing
|
|
31
|
+
|
|
32
|
+
[options]
|
|
33
|
+
include_package_data = True
|
|
34
|
+
entry_points = file: entry_points.txt
|
|
35
|
+
packages = find:
|
|
36
|
+
package_dir = = lib
|
|
37
|
+
python_requires = >=3.9
|
|
38
|
+
tests_require = testtools; coverage
|
|
39
|
+
|
|
40
|
+
[options.packages.find]
|
|
41
|
+
where = lib
|
|
42
|
+
|
|
43
|
+
[options.extras_require]
|
|
44
|
+
wcwidth =
|
|
45
|
+
wcwidth
|
|
46
|
+
|
|
47
|
+
[egg_info]
|
|
48
|
+
tag_build =
|
|
49
|
+
tag_date = 0
|
|
50
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__init__.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__main__.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/annotations.py
RENAMED
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/commands.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/compat.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/config.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/time.py
RENAMED
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/metadata.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/nargs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parse_tree.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parser.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/typing.py
RENAMED
|
File without changes
|
{cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|