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.
- {magicli-2.1.6 → magicli-2.1.7}/PKG-INFO +1 -1
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/PKG-INFO +1 -1
- magicli-2.1.7/magicli.egg-info/scm_version.json +8 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.py +7 -4
- {magicli-2.1.6 → magicli-2.1.7}/tests/test_magicli.py +15 -0
- magicli-2.1.6/magicli.egg-info/scm_version.json +0 -8
- {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/lint.yml +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/pytest.yml +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/.github/workflows/release.yml +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/.gitignore +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/LICENSE +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/README.md +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/docs/img/hello.svg +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/SOURCES.txt +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/dependency_links.txt +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/entry_points.txt +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/requires.txt +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/scm_file_list.json +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/magicli.egg-info/top_level.txt +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/pyproject.toml +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/setup.cfg +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/tests/fixtures.py +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/tests/test_cli.py +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/tests/test_help.py +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/tests/test_parse_kwarg.py +0 -0
- {magicli-2.1.6 → magicli-2.1.7}/tests/test_parse_short_options.py +0 -0
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|