feat(core): clone commands and actions when binding runtimes
Add clone support across Action types and Command so commands can be safely registered or runner-bound without mutating the original instances. - clone BaseAction implementations across simple, composite, IO, prompt, file, HTTP, process, and signal actions - bind cloned commands in Falyx.add_command_from_command() and CommandRunner - preserve local never_prompt settings when cloning actions - rename shared runtime state from options to options_manager for consistency - seed root and execution option namespaces consistently - apply scoped root and namespace option overrides during routing and dispatch - improve namespace completion by delegating option suggestions to FalyxParser - enrich missing-value errors and error hints
This commit is contained in:
@@ -5,7 +5,7 @@ from falyx.action import Action
|
||||
from falyx.console import console as falyx_console
|
||||
from falyx.exceptions import CommandArgumentError, NotAFalyxError
|
||||
from falyx.options_manager import OptionsManager
|
||||
from falyx.parser import ArgumentAction, CommandArgumentParser
|
||||
from falyx.parser import Argument, ArgumentAction, CommandArgumentParser
|
||||
from falyx.signals import HelpSignal
|
||||
|
||||
|
||||
@@ -1009,3 +1009,20 @@ def test_add_argument_invalid_lazy_resolver():
|
||||
CommandArgumentError, match="lazy_resolver must be a boolean, got int"
|
||||
):
|
||||
parser.add_argument("--valid", lazy_resolver=123)
|
||||
|
||||
|
||||
def test_add_argument_returns_registered_argument() -> None:
|
||||
parser = CommandArgumentParser()
|
||||
|
||||
arg = parser.add_argument(
|
||||
"--retries",
|
||||
type=int,
|
||||
default="1",
|
||||
choices=["1", "2"],
|
||||
)
|
||||
|
||||
assert isinstance(arg, Argument)
|
||||
assert arg.dest == "retries"
|
||||
assert arg.default == 1
|
||||
assert arg.choices == [1, 2]
|
||||
assert parser.get_argument("retries") is arg
|
||||
|
||||
Reference in New Issue
Block a user