magicli 2.1.6__tar.gz → 2.1.7__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 (26) hide show
  1. {magicli-2.1.6 → magicli-2.1.7}/PKG-INFO +1 -1
  2. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/PKG-INFO +1 -1
  3. magicli-2.1.7/magicli.egg-info/scm_version.json +8 -0
  4. {magicli-2.1.6 → magicli-2.1.7}/magicli.py +7 -4
  5. {magicli-2.1.6 → magicli-2.1.7}/tests/test_magicli.py +15 -0
  6. magicli-2.1.6/magicli.egg-info/scm_version.json +0 -8
  7. {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/lint.yml +0 -0
  8. {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/pytest.yml +0 -0
  9. {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/release.yml +0 -0
  10. {magicli-2.1.6 → magicli-2.1.7}/.gitignore +0 -0
  11. {magicli-2.1.6 → magicli-2.1.7}/LICENSE +0 -0
  12. {magicli-2.1.6 → magicli-2.1.7}/README.md +0 -0
  13. {magicli-2.1.6 → magicli-2.1.7}/docs/img/hello.svg +0 -0
  14. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/SOURCES.txt +0 -0
  15. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/dependency_links.txt +0 -0
  16. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/entry_points.txt +0 -0
  17. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/requires.txt +0 -0
  18. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/scm_file_list.json +0 -0
  19. {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/top_level.txt +0 -0
  20. {magicli-2.1.6 → magicli-2.1.7}/pyproject.toml +0 -0
  21. {magicli-2.1.6 → magicli-2.1.7}/setup.cfg +0 -0
  22. {magicli-2.1.6 → magicli-2.1.7}/tests/fixtures.py +0 -0
  23. {magicli-2.1.6 → magicli-2.1.7}/tests/test_cli.py +0 -0
  24. {magicli-2.1.6 → magicli-2.1.7}/tests/test_help.py +0 -0
  25. {magicli-2.1.6 → magicli-2.1.7}/tests/test_parse_kwarg.py +0 -0
  26. {magicli-2.1.6 → magicli-2.1.7}/tests/test_parse_short_options.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: magicli
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: Automatically generates a CLI from functions.
5
5
  Author-email: Patrick Elmer <patrick@elmer.ws>
6
6
  License-Expression: GPL-3.0-or-later
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: magicli
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: Automatically generates a CLI from functions.
5
5
  Author-email: Patrick Elmer <patrick@elmer.ws>
6
6
  License-Expression: GPL-3.0-or-later
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "2.1.7",
3
+ "distance": 0,
4
+ "node": "g77bdefe7cdd5b64c471406870859b42350d0f8cc",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-06-24"
8
+ }
@@ -70,7 +70,7 @@ def call(function, argv, module=None, name=None):
70
70
  docstring = inspect.getdoc(function) or ""
71
71
  parameters = inspect.signature(function).parameters
72
72
 
73
- check_for_version(argv, parameters, docstring, module)
73
+ check_for_help_and_version(argv, parameters, docstring, module, function)
74
74
 
75
75
  try:
76
76
  args, kwargs = parse_argv(argv, parameters, docstring)
@@ -200,16 +200,19 @@ def get_type(parameter):
200
200
  return str
201
201
 
202
202
 
203
- def check_for_version(argv, parameters, docstring, module):
203
+ def check_for_help_and_version(argv, parameters, docstring, module, function):
204
204
  """Displays version information if --version is specified in the docstring."""
205
- if "version" in parameters or not module or len(argv) != 1:
205
+ if not module or len(argv) != 1:
206
206
  return
207
+ if argv[0] in ("--help", "-h") and "help" not in parameters:
208
+ logger.info(help_message(help_from_function, function, None, module))
209
+ raise SystemExit
207
210
  args = {
208
211
  "--version": "--version",
209
212
  "-v": "-v, --version",
210
213
  "-V": "-V, --version",
211
214
  }
212
- if (doc := args.get(argv[0])) and doc in docstring:
215
+ if (doc := args.get(argv[0])) and doc in docstring and "version" not in parameters:
213
216
  logger.info(get_version(module))
214
217
  raise SystemExit
215
218
 
@@ -141,3 +141,18 @@ commands:
141
141
  command
142
142
  command_2\
143
143
  """
144
+
145
+ @mock.patch("importlib.import_module", side_effect=module)
146
+ def test_help_kwarg_displays_help_message(mocked, caplog):
147
+ sys.argv = ["name", "--help"]
148
+ name.__doc__ = None
149
+ with pytest.raises(SystemExit):
150
+ magicli()
151
+ doc = """usage:
152
+ name
153
+ name <command>
154
+
155
+ commands:
156
+ command"""
157
+ assert caplog.messages[0] != name.__doc__
158
+ assert caplog.messages[0] == doc
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "2.1.6",
3
- "distance": 0,
4
- "node": "g7e30827f02d07921c90e83b73547295a32bd9915",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-06-23"
8
- }
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