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.
Files changed (65) hide show
  1. {cli_command_parser-2024.12.15/lib/cli_command_parser.egg-info → cli_command_parser-2025.5.10}/PKG-INFO +134 -130
  2. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__version__.py +2 -2
  3. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/choices.py +6 -0
  4. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/actions.py +2 -0
  5. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/testing.py +3 -4
  6. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10/lib/cli_command_parser.egg-info}/PKG-INFO +134 -130
  7. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/readme.rst +4 -1
  8. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/setup.cfg +50 -50
  9. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/LICENSE +0 -0
  10. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/MANIFEST.in +0 -0
  11. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/entry_points.txt +0 -0
  12. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__init__.py +0 -0
  13. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/__main__.py +0 -0
  14. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/annotations.py +0 -0
  15. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/command_parameters.py +0 -0
  16. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/commands.py +0 -0
  17. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/compat.py +0 -0
  18. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/config.py +0 -0
  19. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/context.py +0 -0
  20. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/__init__.py +0 -0
  21. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/__main__.py +0 -0
  22. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/argparse_ast.py +0 -0
  23. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/argparse_utils.py +0 -0
  24. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/cli.py +0 -0
  25. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/command_builder.py +0 -0
  26. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/utils.py +0 -0
  27. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/conversion/visitor.py +0 -0
  28. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/core.py +0 -0
  29. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/documentation.py +0 -0
  30. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/error_handling.py +0 -0
  31. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/exceptions.py +0 -0
  32. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/__init__.py +0 -0
  33. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/commands.py +0 -0
  34. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/params.py +0 -0
  35. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/restructured_text.py +0 -0
  36. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/formatting/utils.py +0 -0
  37. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/__init__.py +0 -0
  38. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/base.py +0 -0
  39. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/exceptions.py +0 -0
  40. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/files.py +0 -0
  41. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/numeric.py +0 -0
  42. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/patterns.py +0 -0
  43. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/time.py +0 -0
  44. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/inputs/utils.py +0 -0
  45. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/metadata.py +0 -0
  46. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/nargs.py +0 -0
  47. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/__init__.py +0 -0
  48. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/base.py +0 -0
  49. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/choice_map.py +0 -0
  50. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/groups.py +0 -0
  51. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/option_strings.py +0 -0
  52. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/options.py +0 -0
  53. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/pass_thru.py +0 -0
  54. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parameters/positionals.py +0 -0
  55. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parse_tree.py +0 -0
  56. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/parser.py +0 -0
  57. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/typing.py +0 -0
  58. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser/utils.py +0 -0
  59. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/SOURCES.txt +0 -0
  60. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/dependency_links.txt +0 -0
  61. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/entry_points.txt +0 -0
  62. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/requires.txt +0 -0
  63. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/lib/cli_command_parser.egg-info/top_level.txt +0 -0
  64. {cli_command_parser-2024.12.15 → cli_command_parser-2025.5.10}/pyproject.toml +0 -0
  65. {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.1
2
- Name: cli_command_parser
3
- Version: 2024.12.15
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
- CLI Command Parser
33
- ##################
34
-
35
- |downloads| |py_version| |coverage_badge| |build_status| |Ruff|
36
-
37
- .. |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
38
- :target: https://pypi.org/project/cli-command-parser/
39
-
40
- .. |coverage_badge| image:: https://codecov.io/gh/dskrypa/cli_command_parser/branch/main/graph/badge.svg
41
- :target: https://codecov.io/gh/dskrypa/cli_command_parser
42
-
43
- .. |build_status| image:: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml/badge.svg
44
- :target: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml
45
-
46
- .. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
47
- :target: https://docs.astral.sh/ruff/
48
-
49
- .. |downloads| image:: https://img.shields.io/pypi/dm/cli-command-parser
50
- :target: https://pypistats.org/packages/cli-command-parser
51
-
52
-
53
- CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the
54
- tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex
55
- CLIs while remaining readable and easy to maintain.
56
-
57
- The primary goals of this project:
58
- - Make it easy to define subcommands and actions in an clean and organized manner
59
- - Allow for inheritance so that common parameters don't need to be repeated
60
- - Make it easy to handle common initialization tasks for all actions / subcommands once
61
- - Reduce the amount of boilerplate code that is necessary for setting up parsing and handling argument values
62
-
63
-
64
- Example Program
65
- ***************
66
-
67
- .. code-block:: python
68
-
69
- from cli_command_parser import Command, Option, main
70
-
71
- class Hello(Command, description='Simple greeting example'):
72
- name = Option('-n', default='World', help='The person to say hello to')
73
- count: int = Option('-c', default=1, help='Number of times to repeat the message')
74
-
75
- def main(self):
76
- for _ in range(self.count):
77
- print(f'Hello {self.name}!')
78
-
79
- if __name__ == '__main__':
80
- main()
81
-
82
-
83
- .. code-block:: shell-session
84
-
85
- $ hello_world.py --name Bob -c 3
86
- Hello Bob!
87
- Hello Bob!
88
- Hello Bob!
89
-
90
- $ hello_world.py -h
91
- usage: hello_world.py [--name NAME] [--count COUNT] [--help]
92
-
93
- Simple greeting example
94
-
95
- Optional arguments:
96
- --name NAME, -n NAME The person to say hello to (default: 'World')
97
- --count COUNT, -c COUNT Number of times to repeat the message (default: 1)
98
- --help, -h Show this help message and exit
99
-
100
-
101
- Installing CLI Command Parser
102
- *****************************
103
-
104
- CLI Command Parser can be installed and updated via `pip <https://pip.pypa.io/en/stable/getting-started/>`__::
105
-
106
- $ pip install -U cli-command-parser
107
-
108
-
109
- There are no required dependencies. Support for formatting wide characters correctly in help text descriptions can
110
- be included by adding `wcwidth <https://wcwidth.readthedocs.io>`__ to your project's requirements, and/or by installing
111
- with optional dependencies::
112
-
113
- $ pip install -U cli-command-parser[wcwidth]
114
-
115
-
116
- Python Version Compatibility
117
- ============================
118
-
119
- Python versions 3.9 and above are currently supported. The last release of CLI Command Parser that supported 3.8 was
120
- 2024-09-07. Support for Python 3.8 `officially ended on 2024-10-07 <https://devguide.python.org/versions/>`__.
121
-
122
-
123
- Links
124
- *****
125
-
126
- - Documentation: https://dskrypa.github.io/cli_command_parser/
127
- - Example Scripts: https://github.com/dskrypa/cli_command_parser/tree/main/examples
128
- - PyPI Releases: https://pypi.org/project/cli-command-parser/
129
- - Source Code: https://github.com/dskrypa/cli_command_parser
130
- - Issue Tracker: https://github.com/dskrypa/cli_command_parser/issues
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,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__ = '2024.12.15'
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 2023 Doug Skrypa'
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
@@ -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
- self._assert_dict_equal(expected, cmd.ctx.get_parsed(cmd, exclude=EXCLUDE_ACTIONS), msg)
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.1
2
- Name: cli_command_parser
3
- Version: 2024.12.15
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
- CLI Command Parser
33
- ##################
34
-
35
- |downloads| |py_version| |coverage_badge| |build_status| |Ruff|
36
-
37
- .. |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
38
- :target: https://pypi.org/project/cli-command-parser/
39
-
40
- .. |coverage_badge| image:: https://codecov.io/gh/dskrypa/cli_command_parser/branch/main/graph/badge.svg
41
- :target: https://codecov.io/gh/dskrypa/cli_command_parser
42
-
43
- .. |build_status| image:: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml/badge.svg
44
- :target: https://github.com/dskrypa/cli_command_parser/actions/workflows/run-tests.yml
45
-
46
- .. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
47
- :target: https://docs.astral.sh/ruff/
48
-
49
- .. |downloads| image:: https://img.shields.io/pypi/dm/cli-command-parser
50
- :target: https://pypistats.org/packages/cli-command-parser
51
-
52
-
53
- CLI Command Parser is a class-based CLI argument parser that defines parameters with descriptors. It provides the
54
- tools to quickly and easily get started with basic CLIs, and it scales well to support even very large and complex
55
- CLIs while remaining readable and easy to maintain.
56
-
57
- The primary goals of this project:
58
- - Make it easy to define subcommands and actions in an clean and organized manner
59
- - Allow for inheritance so that common parameters don't need to be repeated
60
- - Make it easy to handle common initialization tasks for all actions / subcommands once
61
- - Reduce the amount of boilerplate code that is necessary for setting up parsing and handling argument values
62
-
63
-
64
- Example Program
65
- ***************
66
-
67
- .. code-block:: python
68
-
69
- from cli_command_parser import Command, Option, main
70
-
71
- class Hello(Command, description='Simple greeting example'):
72
- name = Option('-n', default='World', help='The person to say hello to')
73
- count: int = Option('-c', default=1, help='Number of times to repeat the message')
74
-
75
- def main(self):
76
- for _ in range(self.count):
77
- print(f'Hello {self.name}!')
78
-
79
- if __name__ == '__main__':
80
- main()
81
-
82
-
83
- .. code-block:: shell-session
84
-
85
- $ hello_world.py --name Bob -c 3
86
- Hello Bob!
87
- Hello Bob!
88
- Hello Bob!
89
-
90
- $ hello_world.py -h
91
- usage: hello_world.py [--name NAME] [--count COUNT] [--help]
92
-
93
- Simple greeting example
94
-
95
- Optional arguments:
96
- --name NAME, -n NAME The person to say hello to (default: 'World')
97
- --count COUNT, -c COUNT Number of times to repeat the message (default: 1)
98
- --help, -h Show this help message and exit
99
-
100
-
101
- Installing CLI Command Parser
102
- *****************************
103
-
104
- CLI Command Parser can be installed and updated via `pip <https://pip.pypa.io/en/stable/getting-started/>`__::
105
-
106
- $ pip install -U cli-command-parser
107
-
108
-
109
- There are no required dependencies. Support for formatting wide characters correctly in help text descriptions can
110
- be included by adding `wcwidth <https://wcwidth.readthedocs.io>`__ to your project's requirements, and/or by installing
111
- with optional dependencies::
112
-
113
- $ pip install -U cli-command-parser[wcwidth]
114
-
115
-
116
- Python Version Compatibility
117
- ============================
118
-
119
- Python versions 3.9 and above are currently supported. The last release of CLI Command Parser that supported 3.8 was
120
- 2024-09-07. Support for Python 3.8 `officially ended on 2024-10-07 <https://devguide.python.org/versions/>`__.
121
-
122
-
123
- Links
124
- *****
125
-
126
- - Documentation: https://dskrypa.github.io/cli_command_parser/
127
- - Example Scripts: https://github.com/dskrypa/cli_command_parser/tree/main/examples
128
- - PyPI Releases: https://pypi.org/project/cli-command-parser/
129
- - Source Code: https://github.com/dskrypa/cli_command_parser
130
- - Issue Tracker: https://github.com/dskrypa/cli_command_parser/issues
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
+