invoke-toolkit 0.0.69__tar.gz → 0.0.70__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.
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/PKG-INFO +1 -1
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/completion.py +64 -2
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/program/program.py +30 -4
- invoke_toolkit-0.0.70/tests/Dockerfile.fish +15 -0
- invoke_toolkit-0.0.70/tests/fish.config.fish +3 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_completion_with_choices.py +99 -1
- invoke_toolkit-0.0.70/tests/test_fish_task.py +44 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/.gitignore +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/LICENSE.txt +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/README.md +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/pyproject.toml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/__main__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/collections.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/config/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/config/config.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/config/registry.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/config/schema.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/config/status_helper.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/context/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/context/async_tools.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/context/context.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/context/types.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/executor.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/config.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/create.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/dist.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/shell.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/field_resolvers.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/loader/entrypoint.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/log/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/log/logger.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/output/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/output/console.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/output/utils.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/parser.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/program/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/program/main.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/py.typed +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/runners/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/runners/rich.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/scripts/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/scripts/loader.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/autocomplete.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/cache.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/fields.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/fields.pyi +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/tasks/types.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/testing.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/utils/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/utils/fzf.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/utils/inspection.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/utils/singleton.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/utils/text.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/copier.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/src/{{package_slug}}/tasks.py.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/copier.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/tests/test_resolver.py.jinja +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/conftest.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/cached_completion/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/completion_with_config/.gitignore +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/completion_with_config/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/config_schema/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/enum_select_size/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/fzf_selector/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/literal_set_level/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/local_field_resolver/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/local_tasks/local_tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/local_tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/conftest.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/test_config_tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/test_create.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/test_package_template_entrypoint.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/test_shell_tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/fixtures/future_fields.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/all-four/invoke.json +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/all-four/invoke.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/all-four/invoke.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/collection.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/echo.yaml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/json/invoke.json +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/json-and-python/invoke.json +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/json-and-python/invoke.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/no-dedupe.yaml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/no-echo.yaml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/package/invoke.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/package/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/python/invoke.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/runtime.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/three-of-em/invoke.json +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/three-of-em/invoke.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/three-of-em/invoke.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/underscores/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yaml/explicit.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yaml/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yml/explicit.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yml/invoke.yml +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yml/tasks.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/has_modules.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/conftest.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/test_config.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/program/main.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/program/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/program/tasks/coll1.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/script/test_script.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/tasks/test_cache.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/tasks/test_extensions_config.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_alias_self_reference.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_annotated_help.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_async_edge_cases.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_async_support.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_cofig_class.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_collection.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_collection_configure.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_config_helper.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_config_registry.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_config_schema.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_console.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_context_class.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_disable_status_cli.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_enum_arguments.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_executor.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_field_typing.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_fields.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_file_completion.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_global_context.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_help_flags.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_invoke_3_compat.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_invoke_compatibility.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_list_filter_flags.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_loader.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_parsing.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_proctitle.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_program_with_collection.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_pty_stdin.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_release_guard.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/test_toplevel.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/typecheck/fields.py +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/typecheck/fields_negative.py.fixture +0 -0
- {invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/utils/test_fzf.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: invoke-toolkit
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.70
|
|
4
4
|
Summary: Extended APIs for PyInvoke: composable task plugins, typed CLI args, Rich output, shell completion, and PEP 723 script support
|
|
5
5
|
Project-URL: Documentation, https://github.com/D3f0/invoke-toolkit#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/D3f0/invoke-toolkit/issues
|
|
@@ -6,12 +6,16 @@ argument values for Enum and Literal parameters.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import glob
|
|
9
|
+
import inspect
|
|
9
10
|
import os
|
|
10
11
|
import re
|
|
11
12
|
import shlex
|
|
12
13
|
from concurrent.futures import ThreadPoolExecutor
|
|
13
14
|
from concurrent.futures import TimeoutError as FuturesTimeoutError
|
|
14
15
|
|
|
16
|
+
from rich.errors import StyleSyntaxError
|
|
17
|
+
from rich.style import Style
|
|
18
|
+
|
|
15
19
|
from invoke.completion.complete import (
|
|
16
20
|
debug,
|
|
17
21
|
print_task_names,
|
|
@@ -28,6 +32,64 @@ from invoke_toolkit.tasks.tasks import (
|
|
|
28
32
|
from invoke_toolkit.tasks.types import _FileCompletionMarker
|
|
29
33
|
|
|
30
34
|
|
|
35
|
+
def _strip_rich_markup(description: str) -> str:
|
|
36
|
+
"""Remove recognized Rich style tags while preserving literal brackets."""
|
|
37
|
+
tag_pattern = re.compile(r"(?P<slashes>\\*)\[(?P<tag>[^\[\]]+)\]")
|
|
38
|
+
open_tags: list[str] = []
|
|
39
|
+
output: list[str] = []
|
|
40
|
+
position = 0
|
|
41
|
+
|
|
42
|
+
for match in tag_pattern.finditer(description):
|
|
43
|
+
output.append(description[position : match.start()])
|
|
44
|
+
slashes = match.group("slashes")
|
|
45
|
+
tag = match.group("tag")
|
|
46
|
+
recognized = False
|
|
47
|
+
if len(slashes) % 2:
|
|
48
|
+
output.append(match.group(0))
|
|
49
|
+
elif tag.startswith("/"):
|
|
50
|
+
name = tag[1:].strip()
|
|
51
|
+
if name == "":
|
|
52
|
+
if open_tags:
|
|
53
|
+
open_tags.pop()
|
|
54
|
+
recognized = True
|
|
55
|
+
else:
|
|
56
|
+
normalized = Style.normalize(name)
|
|
57
|
+
if normalized in open_tags:
|
|
58
|
+
open_tags.remove(normalized)
|
|
59
|
+
recognized = True
|
|
60
|
+
if not recognized:
|
|
61
|
+
output.append(match.group(0))
|
|
62
|
+
else:
|
|
63
|
+
style_name, _, parameters = tag.partition("=")
|
|
64
|
+
try:
|
|
65
|
+
Style.parse(
|
|
66
|
+
style_name if not parameters else f"{style_name}={parameters}"
|
|
67
|
+
)
|
|
68
|
+
except StyleSyntaxError: # A non-style bracket expression is literal text.
|
|
69
|
+
output.append(match.group(0))
|
|
70
|
+
else:
|
|
71
|
+
open_tags.append(Style.normalize(style_name))
|
|
72
|
+
position = match.end()
|
|
73
|
+
|
|
74
|
+
output.append(description[position:])
|
|
75
|
+
return "".join(output).replace(r"\[", "[")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _print_task_names_for_shell(collection) -> None:
|
|
79
|
+
"""Print task names with descriptions when Fish requests completion."""
|
|
80
|
+
if os.environ.get("INVOKE_COMPLETE_SHELL") != "fish":
|
|
81
|
+
print_task_names(collection)
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
for name in sorted(collection.task_names):
|
|
85
|
+
task = collection[name]
|
|
86
|
+
description = " ".join((inspect.getdoc(task) or "").splitlines()).strip()
|
|
87
|
+
description = _strip_rich_markup(description)
|
|
88
|
+
print(f"{name}\t{description}" if description else name)
|
|
89
|
+
for alias in collection.task_names[name]:
|
|
90
|
+
print(alias)
|
|
91
|
+
|
|
92
|
+
|
|
31
93
|
def _get_file_completions(
|
|
32
94
|
marker: "_FileCompletionMarker",
|
|
33
95
|
incomplete: str,
|
|
@@ -361,7 +423,7 @@ def _handle_flag_completion(
|
|
|
361
423
|
if not flag.takes_value:
|
|
362
424
|
# Boolean flags, print task names
|
|
363
425
|
debug("Found, takes no value, printing task names")
|
|
364
|
-
|
|
426
|
+
_print_task_names_for_shell(collection)
|
|
365
427
|
return False
|
|
366
428
|
|
|
367
429
|
# Extract the argument name from the flag object's canonical name
|
|
@@ -672,6 +734,6 @@ def complete_with_choices(
|
|
|
672
734
|
|
|
673
735
|
# Fall back to task name completion
|
|
674
736
|
debug("Last token isn't flag-like, just printing task names")
|
|
675
|
-
|
|
737
|
+
_print_task_names_for_shell(collection)
|
|
676
738
|
|
|
677
739
|
raise Exit
|
|
@@ -7,9 +7,11 @@ It allows three classes to be parametrized: Loader, Config and Executor
|
|
|
7
7
|
__all__ = ["ToolkitProgram"]
|
|
8
8
|
|
|
9
9
|
import ast
|
|
10
|
+
import io
|
|
10
11
|
import asyncio
|
|
11
12
|
import inspect
|
|
12
13
|
import os
|
|
14
|
+
import warnings
|
|
13
15
|
import re
|
|
14
16
|
import sys
|
|
15
17
|
from importlib import import_module, metadata
|
|
@@ -18,6 +20,7 @@ from logging import getLogger
|
|
|
18
20
|
from pathlib import Path
|
|
19
21
|
from typing import Any, Literal
|
|
20
22
|
from collections.abc import Iterator, Sequence
|
|
23
|
+
from contextlib import redirect_stdout
|
|
21
24
|
|
|
22
25
|
from rich.table import Table
|
|
23
26
|
|
|
@@ -68,6 +71,21 @@ def _task_bodies(items: Sequence[Any]) -> Iterator[Any]:
|
|
|
68
71
|
yield item.body
|
|
69
72
|
|
|
70
73
|
|
|
74
|
+
def _print_completion_script(shell: str, names: list[str]) -> None:
|
|
75
|
+
"""Print Invoke's completion script with toolkit shell metadata."""
|
|
76
|
+
output = io.StringIO()
|
|
77
|
+
with redirect_stdout(output):
|
|
78
|
+
print_completion_script(shell=shell, names=names)
|
|
79
|
+
script = output.getvalue()
|
|
80
|
+
if shell == "fish":
|
|
81
|
+
marker = f" {names[0]} --complete --"
|
|
82
|
+
script = script.replace(
|
|
83
|
+
marker,
|
|
84
|
+
f" env INVOKE_COMPLETE_SHELL=fish {names[0]} --complete --",
|
|
85
|
+
)
|
|
86
|
+
print(script, end="")
|
|
87
|
+
|
|
88
|
+
|
|
71
89
|
class ToolkitProgram(Program):
|
|
72
90
|
"""Invoke Toolkit program providing rich output, package versioning and other features"""
|
|
73
91
|
|
|
@@ -103,7 +121,7 @@ class ToolkitProgram(Program):
|
|
|
103
121
|
"""
|
|
104
122
|
return metadata.version("invoke-toolkit")
|
|
105
123
|
|
|
106
|
-
def run(self, argv: list[str] | None = None, exit: bool = True) -> None:
|
|
124
|
+
def run(self, argv: list[str] | None = None, exit: bool = True) -> None: # pylint: disable=too-many-branches
|
|
107
125
|
"""
|
|
108
126
|
Execute main CLI logic, based on ``argv``.
|
|
109
127
|
|
|
@@ -134,8 +152,16 @@ class ToolkitProgram(Program):
|
|
|
134
152
|
# self.tasks (the tasks requested for exec and their own
|
|
135
153
|
# args/flags)
|
|
136
154
|
self.parse_core(argv)
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
if self.args.complete.value:
|
|
156
|
+
with warnings.catch_warnings():
|
|
157
|
+
warnings.filterwarnings(
|
|
158
|
+
"ignore",
|
|
159
|
+
category=RuntimeWarning,
|
|
160
|
+
module=r"invoke_toolkit\.loader\.entrypoint",
|
|
161
|
+
)
|
|
162
|
+
self.parse_collection()
|
|
163
|
+
else:
|
|
164
|
+
self.parse_collection()
|
|
139
165
|
# Parse remainder of argv as task-related input
|
|
140
166
|
self.parse_tasks()
|
|
141
167
|
# End of parsing (typically bailout stuff like --list, --help)
|
|
@@ -266,7 +292,7 @@ class ToolkitProgram(Program):
|
|
|
266
292
|
|
|
267
293
|
# Print (dynamic, no tasks required) completion script if requested
|
|
268
294
|
if self.args["print-completion-script"].value:
|
|
269
|
-
|
|
295
|
+
_print_completion_script(
|
|
270
296
|
shell=self.args["print-completion-script"].value,
|
|
271
297
|
names=self.binary_names,
|
|
272
298
|
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
|
2
|
+
|
|
3
|
+
RUN apt-get update \
|
|
4
|
+
&& apt-get install --no-install-recommends --yes fish git \
|
|
5
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
6
|
+
|
|
7
|
+
RUN uv pip install --system invoke-toolkit
|
|
8
|
+
|
|
9
|
+
ENV PYTHONPATH=/workspace/src
|
|
10
|
+
WORKDIR /workspace
|
|
11
|
+
|
|
12
|
+
COPY tests/fish.config.fish /root/.config/fish/config.fish
|
|
13
|
+
|
|
14
|
+
ENTRYPOINT ["fish"]
|
|
15
|
+
CMD ["--interactive"]
|
|
@@ -5,7 +5,7 @@ import io
|
|
|
5
5
|
import os
|
|
6
6
|
import tempfile
|
|
7
7
|
import time
|
|
8
|
-
from contextlib import redirect_stdout
|
|
8
|
+
from contextlib import redirect_stderr, redirect_stdout
|
|
9
9
|
from enum import Enum
|
|
10
10
|
from typing import Annotated, Literal
|
|
11
11
|
|
|
@@ -46,6 +46,104 @@ def run_completion(coll: ToolkitCollection, task_name: str, flag: str) -> str:
|
|
|
46
46
|
return stdout_capture.getvalue()
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def test_completion_suppresses_entrypoint_warnings(monkeypatch, tmp_path):
|
|
50
|
+
"""Completion output does not leak entry-point warnings to stderr."""
|
|
51
|
+
import warnings
|
|
52
|
+
|
|
53
|
+
from invoke_toolkit.loader.entrypoint import EntryPointLoader
|
|
54
|
+
|
|
55
|
+
(tmp_path / "tasks.py").write_text(
|
|
56
|
+
"from invoke_toolkit import task\n"
|
|
57
|
+
"\n"
|
|
58
|
+
"@task\n"
|
|
59
|
+
"def build(ctx):\n"
|
|
60
|
+
' """Build the project."""\n'
|
|
61
|
+
)
|
|
62
|
+
monkeypatch.chdir(tmp_path)
|
|
63
|
+
|
|
64
|
+
def load_entry_points_with_warning(self):
|
|
65
|
+
warnings.warn("broken completion plugin", RuntimeWarning)
|
|
66
|
+
return {}
|
|
67
|
+
|
|
68
|
+
monkeypatch.setattr(
|
|
69
|
+
EntryPointLoader, "_load_entry_points", load_entry_points_with_warning
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
output = io.StringIO()
|
|
73
|
+
errors = io.StringIO()
|
|
74
|
+
program = TestingToolkitProgram(binary="intk")
|
|
75
|
+
with warnings.catch_warnings(record=True) as seen:
|
|
76
|
+
warnings.simplefilter("always")
|
|
77
|
+
with redirect_stdout(output), redirect_stderr(errors):
|
|
78
|
+
try:
|
|
79
|
+
program.run(["intk", "--complete", "--", "intk"])
|
|
80
|
+
except (SystemExit, Exit):
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
assert errors.getvalue() == ""
|
|
84
|
+
assert [str(item.message) for item in seen] == ["broken completion plugin"]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_fish_completion_includes_task_descriptions(monkeypatch):
|
|
88
|
+
"""Fish completion candidates include the first line of task help."""
|
|
89
|
+
coll = ToolkitCollection()
|
|
90
|
+
|
|
91
|
+
@task
|
|
92
|
+
def deploy(ctx: Context) -> None:
|
|
93
|
+
"""Deploy the [green]application[/green] to a [bold]target[/bold]."""
|
|
94
|
+
|
|
95
|
+
@task
|
|
96
|
+
def clean(ctx: Context) -> None:
|
|
97
|
+
"""Remove generated artifacts."""
|
|
98
|
+
|
|
99
|
+
nested = ToolkitCollection("nested")
|
|
100
|
+
|
|
101
|
+
@task
|
|
102
|
+
def choices(ctx: Context) -> None:
|
|
103
|
+
"""Supports [json, yaml] configuration."""
|
|
104
|
+
|
|
105
|
+
nested.add_task(choices) # type: ignore[arg-type]
|
|
106
|
+
coll.add_collection(nested)
|
|
107
|
+
|
|
108
|
+
coll.add_task(deploy) # type: ignore[arg-type]
|
|
109
|
+
coll.add_task(clean) # type: ignore[arg-type]
|
|
110
|
+
monkeypatch.setenv("INVOKE_COMPLETE_SHELL", "fish")
|
|
111
|
+
|
|
112
|
+
output = run_completion(coll, "", "")
|
|
113
|
+
|
|
114
|
+
assert output.splitlines() == [
|
|
115
|
+
"clean\tRemove generated artifacts.",
|
|
116
|
+
"deploy\tDeploy the application to a target.",
|
|
117
|
+
"nested.choices\tSupports [json, yaml] configuration.",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_fish_completion_preserves_literal_closing_brackets(monkeypatch):
|
|
122
|
+
coll = ToolkitCollection()
|
|
123
|
+
|
|
124
|
+
@task
|
|
125
|
+
def docs(ctx: Context) -> None:
|
|
126
|
+
"""Use the literal [/path] value."""
|
|
127
|
+
|
|
128
|
+
coll.add_task(docs) # type: ignore[arg-type]
|
|
129
|
+
monkeypatch.setenv("INVOKE_COMPLETE_SHELL", "fish")
|
|
130
|
+
|
|
131
|
+
assert run_completion(coll, "", "").splitlines() == [
|
|
132
|
+
"docs\tUse the literal [/path] value."
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_fish_completion_script_exports_completion_shell():
|
|
137
|
+
"""Generated Fish scripts mark their dynamic completion requests."""
|
|
138
|
+
from invoke_toolkit.program.program import _print_completion_script
|
|
139
|
+
|
|
140
|
+
output = io.StringIO()
|
|
141
|
+
with redirect_stdout(output):
|
|
142
|
+
_print_completion_script("fish", ["intk"])
|
|
143
|
+
|
|
144
|
+
assert "env INVOKE_COMPLETE_SHELL=fish intk --complete --" in output.getvalue()
|
|
145
|
+
|
|
146
|
+
|
|
49
147
|
def test_completion_enum_choices():
|
|
50
148
|
"""Test that completion shows enum choices."""
|
|
51
149
|
coll = ToolkitCollection()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from unittest.mock import MagicMock
|
|
3
|
+
|
|
4
|
+
import tasks
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_fish_builds_and_runs_fish_test_container(monkeypatch):
|
|
8
|
+
ctx = MagicMock()
|
|
9
|
+
repo_root = Path("/workspace/invoke-toolkit")
|
|
10
|
+
monkeypatch.setattr(tasks, "REPO_ROOT", repo_root)
|
|
11
|
+
|
|
12
|
+
tasks.fish.body(ctx)
|
|
13
|
+
|
|
14
|
+
assert ctx.run.call_args_list[0].args[0] == (
|
|
15
|
+
"docker build --file /workspace/invoke-toolkit/tests/Dockerfile.fish "
|
|
16
|
+
"--tag invoke-toolkit-fish-test --load /workspace/invoke-toolkit"
|
|
17
|
+
)
|
|
18
|
+
assert ctx.run.call_args_list[1].args[0] == (
|
|
19
|
+
"docker run --rm --interactive --tty "
|
|
20
|
+
"--volume /workspace/invoke-toolkit:/workspace "
|
|
21
|
+
"--workdir /workspace invoke-toolkit-fish-test --interactive"
|
|
22
|
+
)
|
|
23
|
+
assert all(call.kwargs.get("pty") is True for call in ctx.run.call_args_list)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_fish_quotes_paths(monkeypatch):
|
|
27
|
+
ctx = MagicMock()
|
|
28
|
+
monkeypatch.setattr(tasks, "REPO_ROOT", Path("/workspace/repo with spaces"))
|
|
29
|
+
|
|
30
|
+
tasks.fish.body(ctx)
|
|
31
|
+
|
|
32
|
+
assert (
|
|
33
|
+
"'/workspace/repo with spaces/tests/Dockerfile.fish'"
|
|
34
|
+
in (ctx.run.call_args_list[0].args[0])
|
|
35
|
+
)
|
|
36
|
+
assert (
|
|
37
|
+
"'/workspace/repo with spaces:/workspace'"
|
|
38
|
+
in (ctx.run.call_args_list[1].args[0])
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
config = Path("tests/fish.config.fish").read_text(encoding="utf-8")
|
|
42
|
+
|
|
43
|
+
assert "intk -x shell.ic --shell fish" in config
|
|
44
|
+
assert "source ~/.config/fish/completions/intk.fish" in config
|
|
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
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/__init__.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/config.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/create.py
RENAMED
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/src/invoke_toolkit/extensions/tasks/shell.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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/package-template/pyproject.toml.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/.gitignore.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/templates/provider-template/pyproject.toml.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/completion_with_config/.gitignore
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/completion_with_config/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/examples/local_field_resolver/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/extensions/test_package_template_entrypoint.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/collection.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/echo.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/no-echo.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yaml/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/configs/yml/tasks.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.69 → invoke_toolkit-0.0.70}/tests/original_invoke/_support/has_modules.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
|
|
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
|
|
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
|