diff --git a/CHANGELOG.md b/CHANGELOG.md index 23e81db4..4999e88b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +## Alconna 1.7.6 + +### 修复: + +- 修复所有指令都可以响应快捷命令的bug + ## Alconna 1.7.5 ### 改进: diff --git a/src/arclet/alconna/__init__.py b/src/arclet/alconna/__init__.py index 0518a62a..36dfbf80 100644 --- a/src/arclet/alconna/__init__.py +++ b/src/arclet/alconna/__init__.py @@ -21,7 +21,7 @@ from .duplication import Duplication from .stub import ArgsStub, OptionStub, SubcommandStub -__version__ = "1.7.5" +__version__ = "1.7.6" # backward compatibility Arpamar = Arparma diff --git a/src/arclet/alconna/_internal/_analyser.py b/src/arclet/alconna/_internal/_analyser.py index 8ca4b8db..1c652d47 100644 --- a/src/arclet/alconna/_internal/_analyser.py +++ b/src/arclet/alconna/_internal/_analyser.py @@ -285,7 +285,8 @@ def shortcut( """ if isinstance(short, Arparma): return short - argv.build(short.get('command', self.command.command or self.command.name)) + + argv.build(short.get('command', argv.converter(self.command.command) or argv.converter(self.command.name))) if not short.get('fuzzy') and data: exc = ParamsUnmatched(lang.require("analyser", "param_unmatched").format(target=data[0])) if self.command.meta.raise_exception: diff --git a/src/arclet/alconna/manager.py b/src/arclet/alconna/manager.py index 992b7b1b..8b3cbac2 100644 --- a/src/arclet/alconna/manager.py +++ b/src/arclet/alconna/manager.py @@ -248,7 +248,8 @@ def find_shortcut(self, target: Alconna[TDC], query: str | None = None): return self.__shortcuts[f"{namespace}.{name}::{query}"], None except KeyError as e: for k in self.__shortcuts: - if mat := re.match(k.split("::")[1], query): + prefix, key = k.rsplit("::", 1) + if f"{namespace}.{name}" == prefix and (mat := re.match(key, query)): return self.__shortcuts[k], mat raise ValueError( lang.require("manager", "target_command_error").format(target=f"{namespace}.{name}", shortcut=query) diff --git a/tests/core_test.py b/tests/core_test.py index 9f2d27a4..503cf5a2 100644 --- a/tests/core_test.py +++ b/tests/core_test.py @@ -423,7 +423,6 @@ def test_shortcut(): assert not alc16_2.parse("3test").matched - def test_help(): from arclet.alconna.exceptions import SpecialOptionTriggered