invoke-toolkit 0.0.71__tar.gz → 0.0.73__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.71 → invoke_toolkit-0.0.73}/PKG-INFO +1 -1
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/program/program.py +40 -2
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/runners/rich.py +28 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_package_template_entrypoint.py +1 -4
- invoke_toolkit-0.0.73/tests/test_pty_stdin.py +85 -0
- invoke_toolkit-0.0.73/tests/test_task_suggestions.py +120 -0
- invoke_toolkit-0.0.71/tests/test_pty_stdin.py +0 -24
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/.gitignore +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/LICENSE.txt +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/README.md +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/pyproject.toml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/__main__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/collections.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/completion.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/config/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/config/config.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/config/registry.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/config/schema.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/config/status_helper.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/context/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/context/async_tools.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/context/context.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/context/types.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/executor.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/config.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/create.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/dist.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/plugin.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/shell.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/uv_tools.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/field_resolvers.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/loader/entrypoint.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/log/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/log/logger.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/output/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/output/console.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/output/utils.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/parser.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/program/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/program/main.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/py.typed +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/runners/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/scripts/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/scripts/loader.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/autocomplete.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/cache.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/fields.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/fields.pyi +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/tasks/types.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/testing.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/utils/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/utils/fzf.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/utils/inspection.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/utils/singleton.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/utils/text.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/copier.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/package-template/src/{{package_slug}}/tasks.py.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/copier.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/tests/test_resolver.py.jinja +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/conftest.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/cached_completion/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/completion_with_config/.gitignore +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/completion_with_config/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/config_schema/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/enum_select_size/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/fzf_selector/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/literal_set_level/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/local_field_resolver/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/local_tasks/local_tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/examples/local_tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/conftest.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_config_tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_create.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_shell_tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_uv_plugins.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/fixtures/future_fields.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/integration/pty_plugin_completion.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/integration/uv_tool_plugins.sh +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/all-four/invoke.json +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/all-four/invoke.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/all-four/invoke.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/collection.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/echo.yaml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/json/invoke.json +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/json-and-python/invoke.json +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/json-and-python/invoke.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/no-dedupe.yaml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/no-echo.yaml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/package/invoke.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/package/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/python/invoke.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/runtime.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/three-of-em/invoke.json +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/three-of-em/invoke.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/three-of-em/invoke.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/underscores/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yaml/explicit.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yaml/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yml/explicit.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yml/invoke.yml +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yml/tasks.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/has_modules.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/conftest.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/test_config.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/program/main.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/program/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/program/tasks/coll1.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/script/test_script.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/tasks/test_cache.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/tasks/test_extensions_config.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_alias_self_reference.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_annotated_help.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_async_edge_cases.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_async_support.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_cofig_class.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_collection.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_collection_configure.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_completion_with_choices.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_config_helper.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_config_registry.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_config_schema.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_console.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_context_class.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_disable_status_cli.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_enum_arguments.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_executor.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_field_typing.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_fields.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_file_completion.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_global_context.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_help_flags.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_invoke_3_compat.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_invoke_compatibility.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_list_filter_flags.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_loader.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_parsing.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_proctitle.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_program_with_collection.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_release_guard.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/test_toplevel.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/typecheck/fields.py +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/typecheck/fields_negative.py.fixture +0 -0
- {invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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.73
|
|
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
|
|
@@ -12,12 +12,13 @@ import inspect
|
|
|
12
12
|
import os
|
|
13
13
|
import re
|
|
14
14
|
import sys
|
|
15
|
+
from collections.abc import Iterator, Sequence
|
|
16
|
+
from difflib import get_close_matches
|
|
15
17
|
from importlib import import_module, metadata
|
|
16
18
|
from importlib.util import module_from_spec
|
|
17
19
|
from logging import getLogger
|
|
18
20
|
from pathlib import Path
|
|
19
21
|
from typing import Any, Literal
|
|
20
|
-
from collections.abc import Iterator, Sequence
|
|
21
22
|
|
|
22
23
|
from rich.table import Table
|
|
23
24
|
|
|
@@ -297,6 +298,43 @@ class ToolkitProgram(Program):
|
|
|
297
298
|
self.collection, # type: ignore
|
|
298
299
|
)
|
|
299
300
|
|
|
301
|
+
def _suggestion_names(self) -> list[str]:
|
|
302
|
+
"""Return runnable task names, aliases, and collection paths."""
|
|
303
|
+
task_names = self.collection.task_names
|
|
304
|
+
names = [
|
|
305
|
+
*task_names,
|
|
306
|
+
*(alias for aliases in task_names.values() for alias in aliases),
|
|
307
|
+
]
|
|
308
|
+
pending = [("", self.collection)]
|
|
309
|
+
while pending:
|
|
310
|
+
prefix, collection = pending.pop()
|
|
311
|
+
for name, child in collection.collections.items():
|
|
312
|
+
qualified_name = f"{prefix}.{name}" if prefix else name
|
|
313
|
+
names.append(qualified_name)
|
|
314
|
+
pending.append((qualified_name, child))
|
|
315
|
+
return names
|
|
316
|
+
|
|
317
|
+
def _unknown_task_error(self, task_name: str) -> ParseError:
|
|
318
|
+
"""Build an unknown-task error with nearby task and collection names."""
|
|
319
|
+
error = f"No idea what '{task_name}' is!"
|
|
320
|
+
suggestions = get_close_matches(
|
|
321
|
+
task_name, self._suggestion_names(), n=3, cutoff=0.6
|
|
322
|
+
)
|
|
323
|
+
if not suggestions:
|
|
324
|
+
return ParseError(error)
|
|
325
|
+
suggestion = ", ".join(f"'{name}'" for name in suggestions)
|
|
326
|
+
return ParseError(f"{error} Did you mean {suggestion}?")
|
|
327
|
+
|
|
328
|
+
def parse_tasks(self) -> None:
|
|
329
|
+
"""Parse tasks and suggest close names for unknown task tokens."""
|
|
330
|
+
try:
|
|
331
|
+
super().parse_tasks()
|
|
332
|
+
except ParseError as error:
|
|
333
|
+
match = re.fullmatch(r"No idea what '([^']+)' is!", str(error))
|
|
334
|
+
if not match:
|
|
335
|
+
raise
|
|
336
|
+
raise self._unknown_task_error(match.group(1)) from error
|
|
337
|
+
|
|
300
338
|
def print_columns(self, tuples, col_count: int | None = 2):
|
|
301
339
|
print = get_console("out").print
|
|
302
340
|
|
|
@@ -689,7 +727,7 @@ class ToolkitProgram(Program):
|
|
|
689
727
|
else:
|
|
690
728
|
# TODO: feels real dumb to factor this out of Parser, but...we
|
|
691
729
|
# should?
|
|
692
|
-
raise
|
|
730
|
+
raise self._unknown_task_error(halp)
|
|
693
731
|
|
|
694
732
|
# Handle --list / --list-tasks / --list-plugins (raises Exit if triggered)
|
|
695
733
|
self._handle_list_flags()
|
|
@@ -6,9 +6,11 @@ in tasks.
|
|
|
6
6
|
import array
|
|
7
7
|
import errno
|
|
8
8
|
import sys
|
|
9
|
+
from threading import Lock
|
|
9
10
|
from typing import IO, TYPE_CHECKING
|
|
10
11
|
|
|
11
12
|
from invoke.runners import Local, ready_for_reading
|
|
13
|
+
from invoke.terminals import stdin_is_foregrounded_tty
|
|
12
14
|
from invoke.util import debug, has_fileno, isatty
|
|
13
15
|
from rich.syntax import Syntax
|
|
14
16
|
|
|
@@ -25,6 +27,9 @@ if TYPE_CHECKING:
|
|
|
25
27
|
from invoke_toolkit.config.status_helper import StatusHelper
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
_PTY_STDIN_LOCK = Lock()
|
|
31
|
+
|
|
32
|
+
|
|
28
33
|
class RedactingStream:
|
|
29
34
|
"""A file-like wrapper that redacts secrets before writing output."""
|
|
30
35
|
|
|
@@ -131,6 +136,29 @@ class NoStdoutRunner(Local):
|
|
|
131
136
|
bytes_ = self.decode(bytes_)
|
|
132
137
|
return bytes_
|
|
133
138
|
|
|
139
|
+
def handle_stdin(self, input_: IO, output: IO, echo: bool = False) -> None:
|
|
140
|
+
"""Forward PTY input without translating carriage returns to newlines."""
|
|
141
|
+
preserve_carriage_returns = (
|
|
142
|
+
sys.platform != "win32"
|
|
143
|
+
and self.using_pty
|
|
144
|
+
and isatty(input_)
|
|
145
|
+
and has_fileno(input_)
|
|
146
|
+
and stdin_is_foregrounded_tty(input_)
|
|
147
|
+
)
|
|
148
|
+
if not preserve_carriage_returns:
|
|
149
|
+
super().handle_stdin(input_, output, echo)
|
|
150
|
+
return
|
|
151
|
+
|
|
152
|
+
with _PTY_STDIN_LOCK:
|
|
153
|
+
original_settings = termios.tcgetattr(input_)
|
|
154
|
+
forwarding_settings = original_settings.copy()
|
|
155
|
+
forwarding_settings[0] &= ~termios.ICRNL
|
|
156
|
+
termios.tcsetattr(input_, termios.TCSANOW, forwarding_settings)
|
|
157
|
+
try:
|
|
158
|
+
super().handle_stdin(input_, output, echo)
|
|
159
|
+
finally:
|
|
160
|
+
termios.tcsetattr(input_, termios.TCSADRAIN, original_settings)
|
|
161
|
+
|
|
134
162
|
def echo(self, command):
|
|
135
163
|
if hasattr(self.context, "print"):
|
|
136
164
|
# Safety first
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/extensions/test_package_template_entrypoint.py
RENAMED
|
@@ -511,11 +511,8 @@ def test_create_package_refuses_in_git_repo(ctx: Context, git_root: str):
|
|
|
511
511
|
warn=True,
|
|
512
512
|
pty=False,
|
|
513
513
|
)
|
|
514
|
-
# Should fail because location is inside a git repo
|
|
515
514
|
assert not result.ok, "Should refuse to create package in git repo"
|
|
516
|
-
assert
|
|
517
|
-
"Should mention git repository in error message"
|
|
518
|
-
)
|
|
515
|
+
assert not (Path(git_root) / "test-pkg").exists()
|
|
519
516
|
|
|
520
517
|
|
|
521
518
|
@pytest.mark.skipif(not HAS_COPIER, reason="copier not installed")
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import termios
|
|
4
|
+
import textwrap
|
|
5
|
+
import tty
|
|
6
|
+
from contextlib import closing
|
|
7
|
+
|
|
8
|
+
import pexpect
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from invoke_toolkit import Context
|
|
13
|
+
from invoke_toolkit.runners.rich import NoStdoutRunner
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.skipif(os.name == "nt", reason="PTYs are POSIX-only")
|
|
17
|
+
def test_read_our_stdin_handles_escape_sequence_from_pty():
|
|
18
|
+
master_fd, slave_fd = os.openpty()
|
|
19
|
+
try:
|
|
20
|
+
tty.setcbreak(slave_fd)
|
|
21
|
+
os.write(master_fd, b"\x1b[A")
|
|
22
|
+
stream = os.fdopen(slave_fd, "rb", closefd=False)
|
|
23
|
+
with closing(stream):
|
|
24
|
+
runner = NoStdoutRunner(Context())
|
|
25
|
+
runner.encoding = "utf-8"
|
|
26
|
+
assert runner.read_our_stdin(stream) == "\x1b[A"
|
|
27
|
+
finally:
|
|
28
|
+
os.close(master_fd)
|
|
29
|
+
os.close(slave_fd)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.skipif(os.name == "nt", reason="PTYs are POSIX-only")
|
|
33
|
+
def test_pty_run_forwards_enter_as_carriage_return(tmp_path):
|
|
34
|
+
child = tmp_path / "read_enter.py"
|
|
35
|
+
child.write_text(
|
|
36
|
+
textwrap.dedent(
|
|
37
|
+
"""
|
|
38
|
+
import os
|
|
39
|
+
import sys
|
|
40
|
+
import tty
|
|
41
|
+
|
|
42
|
+
tty.setraw(sys.stdin.fileno())
|
|
43
|
+
os.write(sys.stdout.fileno(), b"READY\\n")
|
|
44
|
+
os.read(sys.stdin.fileno(), 1)
|
|
45
|
+
os.write(sys.stdout.fileno(), b"ARMED\\n")
|
|
46
|
+
byte = os.read(sys.stdin.fileno(), 1)
|
|
47
|
+
os.write(sys.stdout.fileno(), b"BYTE:" + byte.hex().encode() + b"\\n")
|
|
48
|
+
"""
|
|
49
|
+
),
|
|
50
|
+
encoding="utf-8",
|
|
51
|
+
)
|
|
52
|
+
parent = tmp_path / "run_child.py"
|
|
53
|
+
parent.write_text(
|
|
54
|
+
textwrap.dedent(
|
|
55
|
+
f"""
|
|
56
|
+
import shlex
|
|
57
|
+
import sys
|
|
58
|
+
|
|
59
|
+
from invoke_toolkit import Config, Context
|
|
60
|
+
|
|
61
|
+
command = shlex.join([sys.executable, {str(child)!r}])
|
|
62
|
+
|
|
63
|
+
Context(config=Config()).run(
|
|
64
|
+
command,
|
|
65
|
+
pty=True,
|
|
66
|
+
echo_stdin=False,
|
|
67
|
+
)
|
|
68
|
+
"""
|
|
69
|
+
),
|
|
70
|
+
encoding="utf-8",
|
|
71
|
+
)
|
|
72
|
+
process = pexpect.spawn(sys.executable, [str(parent)], encoding=None, timeout=5)
|
|
73
|
+
original_settings = termios.tcgetattr(process.child_fd)
|
|
74
|
+
assert original_settings[0] & termios.ICRNL
|
|
75
|
+
try:
|
|
76
|
+
process.expect(b"READY")
|
|
77
|
+
assert process.waitnoecho(timeout=process.timeout)
|
|
78
|
+
process.send(b"!")
|
|
79
|
+
process.expect(b"ARMED")
|
|
80
|
+
process.send(b"\r")
|
|
81
|
+
process.expect(b"BYTE:0d")
|
|
82
|
+
process.expect(pexpect.EOF)
|
|
83
|
+
assert termios.tcgetattr(process.child_fd) == original_settings
|
|
84
|
+
finally:
|
|
85
|
+
process.close(force=True)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from typing import Any, cast
|
|
2
|
+
|
|
3
|
+
from invoke.tasks import Task
|
|
4
|
+
from invoke_toolkit import task
|
|
5
|
+
from invoke_toolkit.collections import ToolkitCollection
|
|
6
|
+
from invoke_toolkit.testing import TestingToolkitProgram
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def collection(*tasks, name: str | None = None) -> ToolkitCollection:
|
|
10
|
+
namespace = ToolkitCollection(name) if name else ToolkitCollection()
|
|
11
|
+
for decorated_task in tasks:
|
|
12
|
+
namespace.add_task(cast(Task[Any], decorated_task))
|
|
13
|
+
return namespace
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def root_with(*collections: ToolkitCollection) -> ToolkitCollection:
|
|
17
|
+
namespace = ToolkitCollection()
|
|
18
|
+
for child in collections:
|
|
19
|
+
namespace.add_collection(child)
|
|
20
|
+
return namespace
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
MISSPELLED_BUILD = "build".replace("l", "")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_unknown_task_suggests_close_task_name(capsys):
|
|
27
|
+
@task
|
|
28
|
+
def build(ctx):
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
program = TestingToolkitProgram(namespace=collection(build))
|
|
32
|
+
program.run(["", MISSPELLED_BUILD], exit=False)
|
|
33
|
+
output = capsys.readouterr().err
|
|
34
|
+
|
|
35
|
+
assert f"No idea what '{MISSPELLED_BUILD}' is!" in output
|
|
36
|
+
assert "Did you mean 'build'?" in output
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_unknown_task_does_not_suggest_distant_task(capsys):
|
|
40
|
+
@task
|
|
41
|
+
def build(ctx):
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
program = TestingToolkitProgram(namespace=collection(build))
|
|
45
|
+
program.run(["", "deploy"], exit=False)
|
|
46
|
+
output = capsys.readouterr().err
|
|
47
|
+
|
|
48
|
+
assert "No idea what 'deploy' is!" in output
|
|
49
|
+
assert "Did you mean" not in output
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_unknown_nested_task_suggests_full_task_name(capsys):
|
|
53
|
+
@task
|
|
54
|
+
def build(ctx):
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
tools = collection(build, name="tools")
|
|
58
|
+
program = TestingToolkitProgram(namespace=root_with(tools))
|
|
59
|
+
program.run(["", f"tools.{MISSPELLED_BUILD}"], exit=False)
|
|
60
|
+
output = capsys.readouterr().err
|
|
61
|
+
|
|
62
|
+
assert f"No idea what 'tools.{MISSPELLED_BUILD}' is!" in output
|
|
63
|
+
assert "Did you mean" in output
|
|
64
|
+
assert "'tools.build'" in output
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_unknown_collection_suggests_close_collection_name(capsys):
|
|
68
|
+
@task
|
|
69
|
+
def build(ctx):
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
tools = collection(build, name="tools")
|
|
73
|
+
program = TestingToolkitProgram(namespace=root_with(tools))
|
|
74
|
+
program.run(["", "tolos"], exit=False)
|
|
75
|
+
output = capsys.readouterr().err
|
|
76
|
+
|
|
77
|
+
assert "No idea what 'tolos' is!" in output
|
|
78
|
+
assert "Did you mean 'tools'?" in output
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_unknown_nested_collection_suggests_full_collection_name(capsys):
|
|
82
|
+
@task
|
|
83
|
+
def deploy(ctx):
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
aws = collection(deploy, name="aws")
|
|
87
|
+
plugins = root_with(aws)
|
|
88
|
+
plugins.name = "plugins"
|
|
89
|
+
program = TestingToolkitProgram(namespace=root_with(plugins))
|
|
90
|
+
program.run(["", "plugins.awz"], exit=False)
|
|
91
|
+
output = capsys.readouterr().err
|
|
92
|
+
|
|
93
|
+
assert "No idea what 'plugins.awz' is!" in output
|
|
94
|
+
assert "'plugins.aws'" in output
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_unknown_task_alias_suggests_close_alias(capsys):
|
|
98
|
+
@task(aliases=["compile"])
|
|
99
|
+
def build(ctx):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
program = TestingToolkitProgram(namespace=collection(build))
|
|
103
|
+
program.run(["", "compiel"], exit=False)
|
|
104
|
+
output = capsys.readouterr().err
|
|
105
|
+
|
|
106
|
+
assert "No idea what 'compiel' is!" in output
|
|
107
|
+
assert "'compile'" in output
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_unknown_help_task_suggests_close_task_name(capsys):
|
|
111
|
+
@task
|
|
112
|
+
def build(ctx):
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
program = TestingToolkitProgram(namespace=collection(build))
|
|
116
|
+
program.run(["", "--help", MISSPELLED_BUILD], exit=False)
|
|
117
|
+
output = capsys.readouterr().err
|
|
118
|
+
|
|
119
|
+
assert f"No idea what '{MISSPELLED_BUILD}' is!" in output
|
|
120
|
+
assert "Did you mean 'build'?" in output
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import tty
|
|
3
|
-
from contextlib import closing
|
|
4
|
-
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from invoke_toolkit import Context
|
|
8
|
-
from invoke_toolkit.runners.rich import NoStdoutRunner
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.mark.skipif(os.name == "nt", reason="PTYs are POSIX-only")
|
|
12
|
-
def test_read_our_stdin_handles_escape_sequence_from_pty():
|
|
13
|
-
master_fd, slave_fd = os.openpty()
|
|
14
|
-
try:
|
|
15
|
-
tty.setcbreak(slave_fd)
|
|
16
|
-
os.write(master_fd, b"\x1b[A")
|
|
17
|
-
stream = os.fdopen(slave_fd, "rb", closefd=False)
|
|
18
|
-
with closing(stream):
|
|
19
|
-
runner = NoStdoutRunner(Context())
|
|
20
|
-
runner.encoding = "utf-8"
|
|
21
|
-
assert runner.read_our_stdin(stream) == "\x1b[A"
|
|
22
|
-
finally:
|
|
23
|
-
os.close(master_fd)
|
|
24
|
-
os.close(slave_fd)
|
|
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.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/__init__.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/config.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/create.py
RENAMED
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/src/invoke_toolkit/extensions/tasks/plugin.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/templates/package-template/pyproject.toml.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/templates/provider-template/.gitignore.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/tests/examples/completion_with_config/.gitignore
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/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
|
|
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.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/collection.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/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.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yaml/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/tests/original_invoke/_support/configs/yml/tasks.py
RENAMED
|
File without changes
|
{invoke_toolkit-0.0.71 → invoke_toolkit-0.0.73}/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
|