magicli 2.1.6__tar.gz → 2.2.0__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.2.0}/PKG-INFO +2 -2
- {magicli-2.1.6 → magicli-2.2.0}/README.md +1 -1
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/PKG-INFO +2 -2
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/SOURCES.txt +0 -1
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/scm_file_list.json +0 -1
- magicli-2.2.0/magicli.egg-info/scm_version.json +8 -0
- {magicli-2.1.6 → magicli-2.2.0}/magicli.py +7 -4
- {magicli-2.1.6 → magicli-2.2.0}/tests/test_magicli.py +15 -0
- magicli-2.1.6/docs/img/hello.svg +0 -1
- magicli-2.1.6/magicli.egg-info/scm_version.json +0 -8
- {magicli-2.1.6 → magicli-2.2.0}/.github/workflows/lint.yml +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/.github/workflows/pytest.yml +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/.github/workflows/release.yml +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/.gitignore +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/LICENSE +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/dependency_links.txt +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/entry_points.txt +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/requires.txt +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/magicli.egg-info/top_level.txt +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/pyproject.toml +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/setup.cfg +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/tests/fixtures.py +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/tests/test_cli.py +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/tests/test_help.py +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/tests/test_parse_kwarg.py +0 -0
- {magicli-2.1.6 → magicli-2.2.0}/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.
|
|
3
|
+
Version: 2.2.0
|
|
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
|
|
@@ -36,7 +36,7 @@ def hello(name, greeting="hello"):
|
|
|
36
36
|
|
|
37
37
|
calling `magicli` creates this CLI:
|
|
38
38
|
|
|
39
|
-

|
|
40
40
|
|
|
41
41
|
(animated terminal created with [clivio](patrickelmer.github.io/clivio))
|
|
42
42
|
|
|
@@ -23,7 +23,7 @@ def hello(name, greeting="hello"):
|
|
|
23
23
|
|
|
24
24
|
calling `magicli` creates this CLI:
|
|
25
25
|
|
|
26
|
-

|
|
27
27
|
|
|
28
28
|
(animated terminal created with [clivio](patrickelmer.github.io/clivio))
|
|
29
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: magicli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
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
|
|
@@ -36,7 +36,7 @@ def hello(name, greeting="hello"):
|
|
|
36
36
|
|
|
37
37
|
calling `magicli` creates this CLI:
|
|
38
38
|
|
|
39
|
-

|
|
40
40
|
|
|
41
41
|
(animated terminal created with [clivio](patrickelmer.github.io/clivio))
|
|
42
42
|
|
|
@@ -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
|
magicli-2.1.6/docs/img/hello.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="540" height="222" font-family="monospace" font-size="18px" fill="#ffffff"><rect width="100%" height="100%" rx="10" fill="#151b23" /><g transform="scale(0.9) translate(20 38)"><text y="0" opacity="0" style="user-select: none;">$ <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0;0;1;1" dur="11s" repeatCount="indefinite" /></text><text x="21.6" y="0" opacity="0">h<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.0545;0.0545;1;1" dur="11s" repeatCount="indefinite" /></text><text x="32.400000000000006" y="0" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.0636;0.0636;1;1" dur="11s" repeatCount="indefinite" /></text><text x="43.2" y="0" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.0727;0.0727;1;1" dur="11s" repeatCount="indefinite" /></text><text x="54" y="0" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.0818;0.0818;1;1" dur="11s" repeatCount="indefinite" /></text><text x="64.80000000000001" y="0" opacity="0">o<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.0909;0.0909;1;1" dur="11s" repeatCount="indefinite" /></text><text x="75.60000000000001" y="0" opacity="0"> <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1;0.1;1;1" dur="11s" repeatCount="indefinite" /></text><text x="86.4" y="0" opacity="0">w<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1091;0.1091;1;1" dur="11s" repeatCount="indefinite" /></text><text x="97.2" y="0" opacity="0">o<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1182;0.1182;1;1" dur="11s" repeatCount="indefinite" /></text><text x="108" y="0" opacity="0">r<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1273;0.1273;1;1" dur="11s" repeatCount="indefinite" /></text><text x="118.80000000000001" y="0" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1364;0.1364;1;1" dur="11s" repeatCount="indefinite" /></text><text x="129.60000000000002" y="0" opacity="0">d<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1455;0.1455;1;1" dur="11s" repeatCount="indefinite" /></text><text y="23" opacity="0">hello world<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1545;0.1545;1;1" dur="11s" repeatCount="indefinite" /></text><text y="46" opacity="0" style="user-select: none;">$ <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.1545;0.1545;1;1" dur="11s" repeatCount="indefinite" /></text><text x="21.6" y="46" opacity="0">h<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3455;0.3455;1;1" dur="11s" repeatCount="indefinite" /></text><text x="32.400000000000006" y="46" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3545;0.3545;1;1" dur="11s" repeatCount="indefinite" /></text><text x="43.2" y="46" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3636;0.3636;1;1" dur="11s" repeatCount="indefinite" /></text><text x="54" y="46" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3727;0.3727;1;1" dur="11s" repeatCount="indefinite" /></text><text x="64.80000000000001" y="46" opacity="0">o<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3818;0.3818;1;1" dur="11s" repeatCount="indefinite" /></text><text y="69" opacity="0">name: positional argument missing<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3909;0.3909;1;1" dur="11s" repeatCount="indefinite" /></text><text y="92" opacity="0"><animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3909;0.3909;1;1" dur="11s" repeatCount="indefinite" /></text><text y="115" opacity="0">usage:<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3909;0.3909;1;1" dur="11s" repeatCount="indefinite" /></text><text y="138" opacity="0">  hello name [--greeting]<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3909;0.3909;1;1" dur="11s" repeatCount="indefinite" /></text><text y="161" opacity="0" style="user-select: none;">$ <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.3909;0.3909;1;1" dur="11s" repeatCount="indefinite" /></text><text x="21.6" y="161" opacity="0">h<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.5818;0.5818;1;1" dur="11s" repeatCount="indefinite" /></text><text x="32.400000000000006" y="161" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.5909;0.5909;1;1" dur="11s" repeatCount="indefinite" /></text><text x="43.2" y="161" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6;0.6;1;1" dur="11s" repeatCount="indefinite" /></text><text x="54" y="161" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6091;0.6091;1;1" dur="11s" repeatCount="indefinite" /></text><text x="64.80000000000001" y="161" opacity="0">o<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6182;0.6182;1;1" dur="11s" repeatCount="indefinite" /></text><text x="75.60000000000001" y="161" opacity="0"> <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6273;0.6273;1;1" dur="11s" repeatCount="indefinite" /></text><text x="86.4" y="161" opacity="0">w<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6364;0.6364;1;1" dur="11s" repeatCount="indefinite" /></text><text x="97.2" y="161" opacity="0">o<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6455;0.6455;1;1" dur="11s" repeatCount="indefinite" /></text><text x="108" y="161" opacity="0">r<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6545;0.6545;1;1" dur="11s" repeatCount="indefinite" /></text><text x="118.80000000000001" y="161" opacity="0">l<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6636;0.6636;1;1" dur="11s" repeatCount="indefinite" /></text><text x="129.60000000000002" y="161" opacity="0">d<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6727;0.6727;1;1" dur="11s" repeatCount="indefinite" /></text><text x="140.4" y="161" opacity="0"> <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6818;0.6818;1;1" dur="11s" repeatCount="indefinite" /></text><text x="151.20000000000002" y="161" opacity="0">-<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.6909;0.6909;1;1" dur="11s" repeatCount="indefinite" /></text><text x="162" y="161" opacity="0">-<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7;0.7;1;1" dur="11s" repeatCount="indefinite" /></text><text x="172.8" y="161" opacity="0">g<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7091;0.7091;1;1" dur="11s" repeatCount="indefinite" /></text><text x="183.60000000000002" y="161" opacity="0">r<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7182;0.7182;1;1" dur="11s" repeatCount="indefinite" /></text><text x="194.4" y="161" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7273;0.7273;1;1" dur="11s" repeatCount="indefinite" /></text><text x="205.20000000000002" y="161" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7364;0.7364;1;1" dur="11s" repeatCount="indefinite" /></text><text x="216" y="161" opacity="0">t<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7455;0.7455;1;1" dur="11s" repeatCount="indefinite" /></text><text x="226.8" y="161" opacity="0">i<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7545;0.7545;1;1" dur="11s" repeatCount="indefinite" /></text><text x="237.60000000000002" y="161" opacity="0">n<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7636;0.7636;1;1" dur="11s" repeatCount="indefinite" /></text><text x="248.4" y="161" opacity="0">g<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7727;0.7727;1;1" dur="11s" repeatCount="indefinite" /></text><text x="259.20000000000005" y="161" opacity="0"> <animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7818;0.7818;1;1" dur="11s" repeatCount="indefinite" /></text><text x="270" y="161" opacity="0">b<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.7909;0.7909;1;1" dur="11s" repeatCount="indefinite" /></text><text x="280.8" y="161" opacity="0">y<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.8;0.8;1;1" dur="11s" repeatCount="indefinite" /></text><text x="291.6" y="161" opacity="0">e<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.8091;0.8091;1;1" dur="11s" repeatCount="indefinite" /></text><text y="184" opacity="0">bye world<animate attributeName="opacity" values="0;0;1;1;0" keyTimes="0;0.8182;0.8182;1;1" dur="11s" repeatCount="indefinite" /></text></g></svg>
|
|
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
|