Skip to content

Commit

Permalink
🚑 version 1.7.6
Browse files Browse the repository at this point in the history
fix shortcut bug
  • Loading branch information
RF-Tar-Railt committed May 20, 2023
1 parent a48f89d commit 0bf0140
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 更新日志

## Alconna 1.7.6

### 修复:

- 修复所有指令都可以响应快捷命令的bug

## Alconna 1.7.5

### 改进:
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/arclet/alconna/_internal/_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/arclet/alconna/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ def test_shortcut():
assert not alc16_2.parse("3test").matched



def test_help():
from arclet.alconna.exceptions import SpecialOptionTriggered

Expand Down

0 comments on commit 0bf0140

Please sign in to comment.