wexample-cli 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/PKG-INFO +4 -4
  2. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/README.md +2 -2
  3. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/pyproject.toml +2 -2
  4. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/command/extended_command.py +21 -0
  5. wexample_cli-0.4.0/src/wexample_cli/helpers/extra_args.py +38 -0
  6. {wexample_cli-0.3.0/tests → wexample_cli-0.4.0/src/wexample_cli/testing}/__init__.py +0 -0
  7. wexample_cli-0.4.0/tests/__init__.py +0 -0
  8. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/__init__.py +0 -0
  9. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/command/__init__.py +0 -0
  10. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/common/__init__.py +0 -0
  11. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/common/command_method_wrapper.py +0 -0
  12. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/const/__init__.py +0 -0
  13. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/const/middleware.py +0 -0
  14. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/const/types.py +0 -0
  15. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/context/__init__.py +0 -0
  16. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/context/execution_context.py +0 -0
  17. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/__init__.py +0 -0
  18. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/alias.py +0 -0
  19. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/as_sudo.py +0 -0
  20. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/command.py +0 -0
  21. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/middleware.py +0 -0
  22. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/option.py +0 -0
  23. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/option_stop_on_failure.py +0 -0
  24. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/decorator/webhook.py +0 -0
  25. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/exception/__init__.py +0 -0
  26. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/exception/abstract_command_option_exception.py +0 -0
  27. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/exception/command_option_missing_exception.py +0 -0
  28. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/exception/command_option_validation_exception.py +0 -0
  29. {wexample_cli-0.3.0/src/wexample_cli/middleware → wexample_cli-0.4.0/src/wexample_cli/helpers}/__init__.py +0 -0
  30. {wexample_cli-0.3.0/src/wexample_cli/testing → wexample_cli-0.4.0/src/wexample_cli/middleware}/__init__.py +0 -0
  31. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/middleware/abstract_middleware.py +0 -0
  32. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/py.typed +0 -0
  33. {wexample_cli-0.3.0 → wexample_cli-0.4.0}/src/wexample_cli/testing/kernel.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wexample-cli
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Reusable CLI primitives — command decorators, options, middlewares, and the enriched command runner — extracted from wex-core so any kernel built on wexample-app can opt in without depending on the full wex framework.
5
5
  Author-Email: weeger <contact@wexample.com>
6
6
  License: MIT
@@ -10,7 +10,7 @@ Classifier: Operating System :: OS Independent
10
10
  Project-URL: homepage, https://github.com/wexample/python-cli
11
11
  Requires-Python: >=3.10
12
12
  Requires-Dist: attrs>=23.1.0
13
- Requires-Dist: wexample-app>=15.2.0
13
+ Requires-Dist: wexample-app>=15.3.0
14
14
  Requires-Dist: wexample-helpers>=13.1.0
15
15
  Requires-Dist: wexample-prompt>=9.1.0
16
16
  Provides-Extra: dev
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  # cli
22
22
 
23
- Version: 0.3.0
23
+ Version: 0.4.0
24
24
 
25
25
  Reusable CLI primitives — command decorators, options, middlewares, and the enriched command runner — extracted from wex-core so any kernel built on wexample-app can opt in without depending on the full wex framework.
26
26
 
@@ -100,7 +100,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
100
100
  ## Dependencies
101
101
 
102
102
  - attrs: >=23.1.0
103
- - wexample-app: >=15.2.0
103
+ - wexample-app: >=15.3.0
104
104
  - wexample-helpers: >=13.1.0
105
105
  - wexample-prompt: >=9.1.0
106
106
 
@@ -1,6 +1,6 @@
1
1
  # cli
2
2
 
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
 
5
5
  Reusable CLI primitives — command decorators, options, middlewares, and the enriched command runner — extracted from wex-core so any kernel built on wexample-app can opt in without depending on the full wex framework.
6
6
 
@@ -80,7 +80,7 @@ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the comp
80
80
  ## Dependencies
81
81
 
82
82
  - attrs: >=23.1.0
83
- - wexample-app: >=15.2.0
83
+ - wexample-app: >=15.3.0
84
84
  - wexample-helpers: >=13.1.0
85
85
  - wexample-prompt: >=9.1.0
86
86
 
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-cli"
9
- version = "0.3.0"
9
+ version = "0.4.0"
10
10
  description = "Reusable CLI primitives — command decorators, options, middlewares, and the enriched command runner — extracted from wex-core so any kernel built on wexample-app can opt in without depending on the full wex framework."
11
11
  authors = [
12
12
  { name = "weeger", email = "contact@wexample.com" },
@@ -19,7 +19,7 @@ classifiers = [
19
19
  ]
20
20
  dependencies = [
21
21
  "attrs>=23.1.0",
22
- "wexample-app>=15.2.0",
22
+ "wexample-app>=15.3.0",
23
23
  "wexample-helpers>=13.1.0",
24
24
  "wexample-prompt>=9.1.0",
25
25
  ]
@@ -226,6 +226,27 @@ class ExtendedCommand(Command):
226
226
  if value is not None:
227
227
  option.value = function_kwargs[option.name] = value
228
228
 
229
+ # `--` passthrough: if the user supplied extra args after `--`, the
230
+ # parser put them in parsed_args["__extra_args__"]. Forward them as
231
+ # `extra_args` if the wrapped function declares that parameter;
232
+ # otherwise raise so misuse fails loudly instead of silently dropping
233
+ # input.
234
+ if "__extra_args__" in parsed_args:
235
+ import inspect
236
+
237
+ sig = inspect.signature(self.command_wrapper.function)
238
+ if "extra_args" in sig.parameters:
239
+ function_kwargs["extra_args"] = parsed_args["__extra_args__"]
240
+ else:
241
+ from wexample_app.exception.command_unexpected_argument_exception import (
242
+ CommandUnexpectedArgumentException,
243
+ )
244
+
245
+ raise CommandUnexpectedArgumentException(
246
+ argument="--",
247
+ allowed_arguments=self.command_wrapper.get_options_names(),
248
+ )
249
+
229
250
  return function_kwargs
230
251
 
231
252
  async def _execute_passes_parallel(
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ import shlex
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from wexample_cli.context.execution_context import ExecutionContext
8
+
9
+
10
+ def resolve_shell_command(
11
+ *,
12
+ context: ExecutionContext,
13
+ command: str | None,
14
+ extra_args: list[str] | None,
15
+ ) -> str | None:
16
+ """Pick the shell command string from `--command "..."` or `-- args...`.
17
+
18
+ Pattern intended for commands that wrap an underlying shell call (SSH,
19
+ docker exec, sub-shell, ...). Returns the resolved command string ready
20
+ to be passed to the remote shell, or None if neither form was provided
21
+ (caller should then error/exit).
22
+
23
+ - `extra_args` (positional, post-`--`) wins over `command` (legacy `-c`),
24
+ because positional form is the one that round-trips complex quoting.
25
+ - Args in `extra_args` are joined with `shlex.join`, which single-quotes
26
+ tokens that need protection — `$VAR` is NOT expanded by the remote
27
+ shell, which is the safer default. Use the legacy `--command "..."`
28
+ form if you intentionally want remote expansion.
29
+ """
30
+ if extra_args and command:
31
+ context.io.warning(
32
+ "Both --command and `-- <args>` were given; using `-- <args>`."
33
+ )
34
+ if extra_args:
35
+ return shlex.join(extra_args)
36
+ if command:
37
+ return command
38
+ return None
File without changes