invoke-toolkit 0.0.72__tar.gz → 0.0.74__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.72 → invoke_toolkit-0.0.74}/PKG-INFO +16 -1
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/README.md +15 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/config/config.py +1 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/create.py +13 -10
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/program/program.py +31 -13
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/runners/rich.py +28 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/test_create.py +16 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/test_package_template_entrypoint.py +1 -4
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_cofig_class.py +6 -0
- invoke_toolkit-0.0.74/tests/test_program_with_collection.py +299 -0
- invoke_toolkit-0.0.74/tests/test_pty_stdin.py +85 -0
- invoke_toolkit-0.0.72/tests/test_program_with_collection.py +0 -84
- invoke_toolkit-0.0.72/tests/test_pty_stdin.py +0 -24
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/.gitignore +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/LICENSE.txt +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/pyproject.toml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/__main__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/collections.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/completion.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/config/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/config/registry.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/config/schema.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/config/status_helper.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/context/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/context/async_tools.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/context/context.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/context/types.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/executor.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/config.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/dist.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/plugin.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/shell.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/uv_tools.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/field_resolvers.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/loader/entrypoint.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/log/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/log/logger.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/output/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/output/console.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/output/utils.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/parser.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/program/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/program/main.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/py.typed +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/runners/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/scripts/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/scripts/loader.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/autocomplete.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/cache.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/fields.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/fields.pyi +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/tasks/types.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/testing.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/utils/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/utils/fzf.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/utils/inspection.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/utils/singleton.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/utils/text.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/copier.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/package-template/src/{{package_slug}}/tasks.py.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/copier.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/templates/provider-template/tests/test_resolver.py.jinja +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/conftest.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/cached_completion/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/completion_with_config/.gitignore +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/completion_with_config/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/config_schema/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/enum_select_size/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/fzf_selector/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/literal_set_level/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/local_field_resolver/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/local_tasks/local_tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/examples/local_tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/conftest.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/test_config_tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/test_shell_tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/extensions/test_uv_plugins.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/fixtures/future_fields.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/integration/pty_plugin_completion.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/integration/uv_tool_plugins.sh +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/all-four/invoke.json +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/all-four/invoke.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/all-four/invoke.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/collection.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/echo.yaml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/json/invoke.json +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/json-and-python/invoke.json +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/json-and-python/invoke.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/no-dedupe.yaml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/no-echo.yaml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/package/invoke.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/package/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/python/invoke.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/runtime.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/three-of-em/invoke.json +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/three-of-em/invoke.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/three-of-em/invoke.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/underscores/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/yaml/explicit.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/yaml/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/yml/explicit.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/yml/invoke.yml +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/configs/yml/tasks.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/_support/has_modules.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/conftest.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/original_invoke/test_config.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/program/main.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/program/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/program/tasks/coll1.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/script/test_script.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/tasks/test_cache.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/tasks/test_extensions_config.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_alias_self_reference.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_annotated_help.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_async_edge_cases.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_async_support.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_collection.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_collection_configure.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_completion_with_choices.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_config_helper.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_config_registry.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_config_schema.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_console.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_context_class.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_disable_status_cli.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_enum_arguments.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_executor.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_field_typing.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_fields.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_file_completion.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_global_context.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_help_flags.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_invoke_3_compat.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_invoke_compatibility.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_list_filter_flags.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_loader.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_parsing.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_proctitle.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_release_guard.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_task_suggestions.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/test_toplevel.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/typecheck/fields.py +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/tests/typecheck/fields_negative.py.fixture +0 -0
- {invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/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.74
|
|
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
|
|
@@ -262,6 +262,21 @@ do not update invoke-toolkit itself.
|
|
|
262
262
|
Shell completion suggests directly installed plugin names for `plugin.remove`
|
|
263
263
|
and named `plugin.update` operations.
|
|
264
264
|
|
|
265
|
+
To reduce shell-completion latency in environments with expensive collection
|
|
266
|
+
plugins, set `completion.disable_plugins: true` in `invoke.yaml`:
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
completion:
|
|
270
|
+
disable_plugins: true
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
`INVOKE_COMPLETION_DISABLE_PLUGINS=1` enables the same behavior without changing
|
|
274
|
+
the configuration file. Completion then skips installed
|
|
275
|
+
`invoke_toolkit.collection` entry points while retaining project, local, and
|
|
276
|
+
built-in `-x` task suggestions. These settings affect completion only; normal
|
|
277
|
+
task execution and listing still load plugins.
|
|
278
|
+
|
|
279
|
+
|
|
265
280
|
|
|
266
281
|
These commands reject `uvx`, `uv run`, project environments, and installations
|
|
267
282
|
managed by another tool. pipx offers a similar manual workflow:
|
|
@@ -201,6 +201,21 @@ do not update invoke-toolkit itself.
|
|
|
201
201
|
Shell completion suggests directly installed plugin names for `plugin.remove`
|
|
202
202
|
and named `plugin.update` operations.
|
|
203
203
|
|
|
204
|
+
To reduce shell-completion latency in environments with expensive collection
|
|
205
|
+
plugins, set `completion.disable_plugins: true` in `invoke.yaml`:
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
completion:
|
|
209
|
+
disable_plugins: true
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`INVOKE_COMPLETION_DISABLE_PLUGINS=1` enables the same behavior without changing
|
|
213
|
+
the configuration file. Completion then skips installed
|
|
214
|
+
`invoke_toolkit.collection` entry points while retaining project, local, and
|
|
215
|
+
built-in `-x` task suggestions. These settings affect completion only; normal
|
|
216
|
+
task execution and listing still load plugins.
|
|
217
|
+
|
|
218
|
+
|
|
204
219
|
|
|
205
220
|
These commands reject `uvx`, `uv run`, project environments, and installations
|
|
206
221
|
managed by another tool. pipx offers a similar manual workflow:
|
|
@@ -101,6 +101,7 @@ class ToolkitConfig(Config):
|
|
|
101
101
|
ret["init_shell"] = False
|
|
102
102
|
ret["completion"] = {
|
|
103
103
|
"callback_timeout": 10.0, # Timeout in seconds for completion callbacks
|
|
104
|
+
"disable_plugins": False, # Skip entry-point plugins during completion
|
|
104
105
|
}
|
|
105
106
|
ret["fuzzy_finder"] = {
|
|
106
107
|
"show_warnings": True, # Show warning when fzf is not available
|
{invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/src/invoke_toolkit/extensions/tasks/create.py
RENAMED
|
@@ -19,16 +19,23 @@ import invoke_toolkit
|
|
|
19
19
|
from invoke_toolkit import Context, __version__, task
|
|
20
20
|
from invoke_toolkit.loader.entrypoint import COLLECTION_ENTRY_POINT, PLUGIN_PREFIX
|
|
21
21
|
|
|
22
|
-
try:
|
|
23
|
-
from copier import run_copy
|
|
24
|
-
except ImportError:
|
|
25
|
-
run_copy = None # type: ignore[assignment]
|
|
26
|
-
|
|
27
22
|
|
|
28
23
|
# Git config key for custom template repository/path
|
|
29
24
|
GIT_CONFIG_TEMPLATE_KEY = "invoke-toolkit.package-template"
|
|
30
25
|
|
|
31
26
|
|
|
27
|
+
def _load_copier(ctx: Context):
|
|
28
|
+
"""Load Copier only when package generation needs it."""
|
|
29
|
+
try:
|
|
30
|
+
from copier import run_copy # pylint: disable=import-outside-toplevel
|
|
31
|
+
except ImportError:
|
|
32
|
+
ctx.rich_exit(
|
|
33
|
+
"copier is required to create packages. "
|
|
34
|
+
"Install it with: uv pip install invoke-toolkit[copier]"
|
|
35
|
+
)
|
|
36
|
+
return run_copy
|
|
37
|
+
|
|
38
|
+
|
|
32
39
|
def _get_git_config_value(key: str) -> str | None:
|
|
33
40
|
"""
|
|
34
41
|
Get a value from git config.
|
|
@@ -272,11 +279,7 @@ def package(
|
|
|
272
279
|
Provider packages contain only a field-resolver entry point and never expose
|
|
273
280
|
invoke-toolkit task collections.
|
|
274
281
|
"""
|
|
275
|
-
|
|
276
|
-
ctx.rich_exit(
|
|
277
|
-
"copier is required to create packages. "
|
|
278
|
-
"Install it with: uv pip install invoke-toolkit[copier]"
|
|
279
|
-
)
|
|
282
|
+
run_copy = _load_copier(ctx)
|
|
280
283
|
|
|
281
284
|
if provider and (name or ext_name or template):
|
|
282
285
|
ctx.rich_exit(
|
|
@@ -605,17 +605,29 @@ class ToolkitProgram(Program):
|
|
|
605
605
|
)
|
|
606
606
|
# Load local tasks if they exist
|
|
607
607
|
self.collection.load_local_tasks(search_path=parent)
|
|
608
|
-
# Also try to load entry points (merge with tasks.py)
|
|
609
|
-
|
|
610
|
-
if
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
608
|
+
# Also try to load entry points (merge with tasks.py), unless the
|
|
609
|
+
# user opted out of plugin discovery for latency-sensitive completion.
|
|
610
|
+
if not self._completion_plugins_disabled():
|
|
611
|
+
ep_collection = self._load_entry_points_collection(parent)
|
|
612
|
+
if ep_collection is not None:
|
|
613
|
+
debug("Merging entry point collections with tasks.py")
|
|
614
|
+
for name, collection in ep_collection.collections.items():
|
|
615
|
+
self.collection.add_collection(collection, name=name)
|
|
616
|
+
self._plugin_collection_names.add(name)
|
|
615
617
|
except CollectionNotFound as e:
|
|
616
|
-
start =
|
|
617
|
-
#
|
|
618
|
-
|
|
618
|
+
start = start or "."
|
|
619
|
+
# A missing tasks.py cannot provide the project location, so load
|
|
620
|
+
# configuration from the resolved search root before deciding
|
|
621
|
+
# whether completion should discover entry-point plugins.
|
|
622
|
+
self.config.set_project_location(start)
|
|
623
|
+
self.config.load_project()
|
|
624
|
+
# First try entry points for packages without tasks.py. Completion
|
|
625
|
+
# may explicitly skip this potentially expensive plugin discovery.
|
|
626
|
+
ep_collection = (
|
|
627
|
+
None
|
|
628
|
+
if self._completion_plugins_disabled()
|
|
629
|
+
else self._load_entry_points_collection(start)
|
|
630
|
+
)
|
|
619
631
|
if ep_collection is not None:
|
|
620
632
|
debug("Loading collections from entry points")
|
|
621
633
|
self.collection = ep_collection
|
|
@@ -643,9 +655,6 @@ class ToolkitProgram(Program):
|
|
|
643
655
|
debug("No collection found, will checking for internal")
|
|
644
656
|
else:
|
|
645
657
|
debug("No tasks.py found, but local_tasks.py exists, continuing...")
|
|
646
|
-
start = self.args["search-root"].value
|
|
647
|
-
self.config.set_project_location(start)
|
|
648
|
-
self.config.load_project()
|
|
649
658
|
self.collection = ToolkitCollection(EMPTY_COLLECTION_NAME)
|
|
650
659
|
# Try to load local tasks if they exist
|
|
651
660
|
self.collection.load_local_tasks(search_path=start)
|
|
@@ -668,6 +677,15 @@ class ToolkitProgram(Program):
|
|
|
668
677
|
"""Flat arguments"""
|
|
669
678
|
return {name: arg.value for name, arg in self.args.items()}
|
|
670
679
|
|
|
680
|
+
def _completion_plugins_disabled(self) -> bool:
|
|
681
|
+
"""Return whether this completion request excludes entry-point plugins."""
|
|
682
|
+
if not self.args.complete.value:
|
|
683
|
+
return False
|
|
684
|
+
return bool(
|
|
685
|
+
self.config.completion.disable_plugins
|
|
686
|
+
or env_enabled(os.getenv("INVOKE_COMPLETION_DISABLE_PLUGINS", "0"))
|
|
687
|
+
)
|
|
688
|
+
|
|
671
689
|
def _has_internal_col_flag_in_completion(self) -> bool:
|
|
672
690
|
"""
|
|
673
691
|
Check if -x or --internal-col flag is present in the completion context.
|
|
@@ -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
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import builtins
|
|
2
3
|
import subprocess
|
|
3
4
|
import typing
|
|
4
5
|
from pathlib import Path
|
|
@@ -11,6 +12,7 @@ from invoke_toolkit.context.context import ToolkitContext
|
|
|
11
12
|
from invoke_toolkit.extensions.tasks.create import (
|
|
12
13
|
GIT_CONFIG_TEMPLATE_KEY,
|
|
13
14
|
_get_git_config_value,
|
|
15
|
+
_load_copier,
|
|
14
16
|
)
|
|
15
17
|
from invoke_toolkit.testing import TestingToolkitProgram
|
|
16
18
|
|
|
@@ -18,6 +20,20 @@ if typing.TYPE_CHECKING:
|
|
|
18
20
|
from tests.conftest import ShellRunTmp, TempVenv
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
def test_load_copier_exits_when_optional_dependency_is_missing(monkeypatch, ctx):
|
|
24
|
+
real_import = builtins.__import__
|
|
25
|
+
|
|
26
|
+
def import_without_copier(name, *args, **kwargs):
|
|
27
|
+
if name == "copier":
|
|
28
|
+
raise ImportError("copier unavailable")
|
|
29
|
+
return real_import(name, *args, **kwargs)
|
|
30
|
+
|
|
31
|
+
monkeypatch.setattr(builtins, "__import__", import_without_copier)
|
|
32
|
+
|
|
33
|
+
with pytest.raises(SystemExit):
|
|
34
|
+
_load_copier(ctx)
|
|
35
|
+
|
|
36
|
+
|
|
21
37
|
def test_new_script_has_hello_world_task(
|
|
22
38
|
tmp_path: Path,
|
|
23
39
|
monkeypatch: pytest.MonkeyPatch,
|
{invoke_toolkit-0.0.72 → invoke_toolkit-0.0.74}/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,299 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import pkgutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from invoke_toolkit import Context, task
|
|
10
|
+
from invoke_toolkit.collections import ToolkitCollection
|
|
11
|
+
from invoke_toolkit.extensions import tasks as extensions_tasks
|
|
12
|
+
from invoke_toolkit.testing import TestingToolkitProgram
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_extension_collection_names() -> set[str]:
|
|
16
|
+
"""Dynamically discover all extension collection names."""
|
|
17
|
+
return {module.name for module in pkgutil.iter_modules(extensions_tasks.__path__)}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _install_completion_plugin(path: Path) -> Path:
|
|
21
|
+
"""Create importable plugin metadata and return its import sentinel path."""
|
|
22
|
+
sentinel = path / "plugin-imported"
|
|
23
|
+
(path / "fixture_plugin.py").write_text(
|
|
24
|
+
"from pathlib import Path\n"
|
|
25
|
+
"from invoke_toolkit import Collection, task\n"
|
|
26
|
+
f"Path({str(sentinel)!r}).touch()\n"
|
|
27
|
+
"@task\n"
|
|
28
|
+
"def marker(ctx):\n"
|
|
29
|
+
" pass\n"
|
|
30
|
+
"collection = Collection(marker)\n",
|
|
31
|
+
encoding="utf-8",
|
|
32
|
+
)
|
|
33
|
+
metadata = path / "fixture_plugin-1.0.dist-info"
|
|
34
|
+
metadata.mkdir()
|
|
35
|
+
(metadata / "METADATA").write_text(
|
|
36
|
+
"Metadata-Version: 2.1\nName: fixture-plugin\nVersion: 1.0\n",
|
|
37
|
+
encoding="utf-8",
|
|
38
|
+
)
|
|
39
|
+
(metadata / "entry_points.txt").write_text(
|
|
40
|
+
"[invoke_toolkit.collection]\nfixture-plugin = fixture_plugin:collection\n",
|
|
41
|
+
encoding="utf-8",
|
|
42
|
+
)
|
|
43
|
+
return sentinel
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _complete_from(
|
|
47
|
+
path: Path,
|
|
48
|
+
*,
|
|
49
|
+
disable_plugins: bool,
|
|
50
|
+
completion_args: list[str] | None = None,
|
|
51
|
+
) -> subprocess.CompletedProcess:
|
|
52
|
+
env = os.environ.copy()
|
|
53
|
+
env["PYTHONPATH"] = os.pathsep.join(
|
|
54
|
+
part for part in (str(path), env.get("PYTHONPATH", "")) if part
|
|
55
|
+
)
|
|
56
|
+
if disable_plugins:
|
|
57
|
+
env["INVOKE_COMPLETION_DISABLE_PLUGINS"] = "1"
|
|
58
|
+
else:
|
|
59
|
+
env.pop("INVOKE_COMPLETION_DISABLE_PLUGINS", None)
|
|
60
|
+
return subprocess.run(
|
|
61
|
+
[
|
|
62
|
+
sys.executable,
|
|
63
|
+
"-m",
|
|
64
|
+
"invoke_toolkit",
|
|
65
|
+
"--complete",
|
|
66
|
+
"--",
|
|
67
|
+
"intk",
|
|
68
|
+
*(completion_args or []),
|
|
69
|
+
],
|
|
70
|
+
cwd=path,
|
|
71
|
+
env=env,
|
|
72
|
+
capture_output=True,
|
|
73
|
+
text=True,
|
|
74
|
+
check=False,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@task()
|
|
79
|
+
def example_task_1(ctx: Context):
|
|
80
|
+
ctx.run("echo example_task_1")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@task()
|
|
84
|
+
def example_task_2(ctx: Context):
|
|
85
|
+
ctx.run("echo example_task_2")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_program_with_collection(capsys, suppress_stderr_logging):
|
|
89
|
+
# verify that when the flag -x is passed, the extra collections are also listed
|
|
90
|
+
coll = ToolkitCollection()
|
|
91
|
+
coll.add_task(example_task_1)
|
|
92
|
+
coll.add_task(example_task_2)
|
|
93
|
+
|
|
94
|
+
p = TestingToolkitProgram(namespace=coll)
|
|
95
|
+
p.run(["", "-xl", "--list-format", "json"])
|
|
96
|
+
out, err = capsys.readouterr()
|
|
97
|
+
assert not err, f"There should be no err output: {err}"
|
|
98
|
+
task_list: dict[str, Any] = json.loads(out)
|
|
99
|
+
collections = task_list.get("collections")
|
|
100
|
+
assert collections, "collections not found in -x"
|
|
101
|
+
expected_collections = get_extension_collection_names()
|
|
102
|
+
actual_collections = set(c["name"] for c in collections)
|
|
103
|
+
assert actual_collections.issubset(expected_collections), (
|
|
104
|
+
f"Unexpected collections: {actual_collections - expected_collections}"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_completion_with_x_flag(suppress_stderr_logging):
|
|
109
|
+
"""Test that completion includes internal collections when -x is passed"""
|
|
110
|
+
result = subprocess.run(
|
|
111
|
+
[sys.executable, "-m", "invoke_toolkit", "--complete", "--", "intk", "-x"],
|
|
112
|
+
capture_output=True,
|
|
113
|
+
text=True,
|
|
114
|
+
check=False,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
output = result.stdout + result.stderr
|
|
118
|
+
|
|
119
|
+
# Check that internal collections are in the completion output
|
|
120
|
+
assert "config" in output, "config collection should be in completion with -x"
|
|
121
|
+
assert "create" in output, "create collection should be in completion with -x"
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_completion_loads_entry_point_plugins_by_default(tmp_path):
|
|
125
|
+
sentinel = _install_completion_plugin(tmp_path)
|
|
126
|
+
|
|
127
|
+
result = _complete_from(tmp_path, disable_plugins=False)
|
|
128
|
+
|
|
129
|
+
assert result.returncode == 0, result.stderr
|
|
130
|
+
assert "fixture-plugin.marker" in result.stdout
|
|
131
|
+
assert sentinel.exists()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def test_completion_can_skip_entry_point_plugins(tmp_path):
|
|
135
|
+
sentinel = _install_completion_plugin(tmp_path)
|
|
136
|
+
(tmp_path / "tasks.py").write_text(
|
|
137
|
+
"from invoke_toolkit import Collection, task\n"
|
|
138
|
+
"@task\n"
|
|
139
|
+
"def project_marker(ctx):\n"
|
|
140
|
+
" pass\n"
|
|
141
|
+
"ns = Collection(project_marker)\n",
|
|
142
|
+
encoding="utf-8",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
result = _complete_from(tmp_path, disable_plugins=True)
|
|
146
|
+
|
|
147
|
+
assert result.returncode == 0, result.stderr
|
|
148
|
+
assert "fixture-plugin.marker" not in result.stdout
|
|
149
|
+
assert "project-marker" in result.stdout
|
|
150
|
+
assert not sentinel.exists()
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_completion_can_skip_entry_point_plugins_from_project_config(tmp_path):
|
|
154
|
+
sentinel = _install_completion_plugin(tmp_path)
|
|
155
|
+
(tmp_path / "tasks.py").write_text(
|
|
156
|
+
"from invoke_toolkit import Collection, task\n"
|
|
157
|
+
"@task\n"
|
|
158
|
+
"def project_marker(ctx):\n"
|
|
159
|
+
" pass\n"
|
|
160
|
+
"ns = Collection(project_marker)\n",
|
|
161
|
+
encoding="utf-8",
|
|
162
|
+
)
|
|
163
|
+
(tmp_path / "invoke.yaml").write_text(
|
|
164
|
+
"completion:\n disable_plugins: true\n",
|
|
165
|
+
encoding="utf-8",
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
result = _complete_from(tmp_path, disable_plugins=False)
|
|
169
|
+
|
|
170
|
+
assert result.returncode == 0, result.stderr
|
|
171
|
+
assert "fixture-plugin.marker" not in result.stdout
|
|
172
|
+
assert "project-marker" in result.stdout
|
|
173
|
+
assert not sentinel.exists()
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_completion_can_skip_plugins_from_config_without_tasks_file(tmp_path):
|
|
177
|
+
sentinel = _install_completion_plugin(tmp_path)
|
|
178
|
+
(tmp_path / "invoke.yaml").write_text(
|
|
179
|
+
"completion:\n disable_plugins: true\n",
|
|
180
|
+
encoding="utf-8",
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
result = _complete_from(tmp_path, disable_plugins=False)
|
|
184
|
+
|
|
185
|
+
assert result.returncode == 0, result.stderr
|
|
186
|
+
assert "fixture-plugin.marker" not in result.stdout
|
|
187
|
+
assert not sentinel.exists()
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def test_completion_search_root_keeps_local_tasks_when_plugins_disabled(tmp_path):
|
|
191
|
+
project_path = tmp_path / "project"
|
|
192
|
+
project_path.mkdir()
|
|
193
|
+
(project_path / "local_tasks.py").write_text(
|
|
194
|
+
"from invoke_toolkit import task\n@task\ndef local_marker(ctx):\n pass\n",
|
|
195
|
+
encoding="utf-8",
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
result = _complete_from(
|
|
199
|
+
tmp_path,
|
|
200
|
+
disable_plugins=True,
|
|
201
|
+
completion_args=["--search-root", str(project_path), "local."],
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
assert result.returncode == 0, result.stderr
|
|
205
|
+
assert "local.local-marker" in result.stdout
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_plugin_completion_opt_out_does_not_affect_execution(tmp_path):
|
|
209
|
+
sentinel = _install_completion_plugin(tmp_path)
|
|
210
|
+
env = os.environ.copy()
|
|
211
|
+
env["PYTHONPATH"] = os.pathsep.join(
|
|
212
|
+
part for part in (str(tmp_path), env.get("PYTHONPATH", "")) if part
|
|
213
|
+
)
|
|
214
|
+
env["INVOKE_COMPLETION_DISABLE_PLUGINS"] = "1"
|
|
215
|
+
|
|
216
|
+
result = subprocess.run(
|
|
217
|
+
[sys.executable, "-m", "invoke_toolkit", "--list"],
|
|
218
|
+
cwd=tmp_path,
|
|
219
|
+
env=env,
|
|
220
|
+
capture_output=True,
|
|
221
|
+
text=True,
|
|
222
|
+
check=False,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
assert result.returncode == 0, result.stderr
|
|
226
|
+
assert "fixture-plugin.marker" in result.stdout
|
|
227
|
+
assert sentinel.exists()
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_plugin_completion_opt_out_keeps_internal_collections(tmp_path):
|
|
231
|
+
env = os.environ.copy()
|
|
232
|
+
env["INVOKE_COMPLETION_DISABLE_PLUGINS"] = "1"
|
|
233
|
+
|
|
234
|
+
result = subprocess.run(
|
|
235
|
+
[
|
|
236
|
+
sys.executable,
|
|
237
|
+
"-m",
|
|
238
|
+
"invoke_toolkit",
|
|
239
|
+
"--complete",
|
|
240
|
+
"--",
|
|
241
|
+
"intk",
|
|
242
|
+
"-x",
|
|
243
|
+
],
|
|
244
|
+
cwd=tmp_path,
|
|
245
|
+
env=env,
|
|
246
|
+
capture_output=True,
|
|
247
|
+
text=True,
|
|
248
|
+
check=False,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
assert result.returncode == 0, result.stderr
|
|
252
|
+
assert "config" in result.stdout
|
|
253
|
+
assert "create" in result.stdout
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def test_internal_completion_does_not_import_copier():
|
|
257
|
+
"""Completing built-in task names must not load the optional Copier stack."""
|
|
258
|
+
result = subprocess.run(
|
|
259
|
+
[
|
|
260
|
+
sys.executable,
|
|
261
|
+
"-c",
|
|
262
|
+
(
|
|
263
|
+
"import sys; "
|
|
264
|
+
"from invoke_toolkit.testing import TestingToolkitProgram; "
|
|
265
|
+
"TestingToolkitProgram().run("
|
|
266
|
+
"['intk', '--complete', '--', 'intk', '-x'], exit=False); "
|
|
267
|
+
"assert 'copier' not in sys.modules, "
|
|
268
|
+
"'copier imported during completion'"
|
|
269
|
+
),
|
|
270
|
+
],
|
|
271
|
+
capture_output=True,
|
|
272
|
+
text=True,
|
|
273
|
+
check=False,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
assert result.returncode == 0, result.stderr
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def test_completion_without_x_flag(suppress_stderr_logging):
|
|
280
|
+
"""Test that completion does not include internal collections without -x"""
|
|
281
|
+
result = subprocess.run(
|
|
282
|
+
[sys.executable, "-m", "invoke_toolkit", "--complete", "--", "intk"],
|
|
283
|
+
capture_output=True,
|
|
284
|
+
text=True,
|
|
285
|
+
check=False,
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
output = result.stdout + result.stderr
|
|
289
|
+
lines = output.strip().split("\n")
|
|
290
|
+
|
|
291
|
+
# Count how many internal collection items appear
|
|
292
|
+
internal_items = sum(
|
|
293
|
+
1 for line in lines if "config." in line or "create." in line or "dist." in line
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
# There should be no internal collection items without -x
|
|
297
|
+
assert internal_items == 0, (
|
|
298
|
+
f"Found {internal_items} internal collection items without -x flag"
|
|
299
|
+
)
|
|
@@ -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)
|