mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
⚡ store message in ParserExit exception
This commit is contained in:
parent
b861149e0b
commit
1f585d8bcb
@ -294,7 +294,8 @@ class ArgumentParser(ArgParser):
|
||||
setattr(self, "message", old_message)
|
||||
|
||||
def exit(self, status=0, message=None):
|
||||
raise ParserExit(status=status, message=message)
|
||||
raise ParserExit(status=status,
|
||||
message=message or getattr(self, "message", None))
|
||||
|
||||
def parse_args(self,
|
||||
args: Optional[Sequence[str]] = None,
|
||||
@ -369,7 +370,7 @@ def shell_command(*cmds: Union[str, Tuple[str, ...]],
|
||||
args = parser.parse_args(state["argv"])
|
||||
state["args"] = args
|
||||
except ParserExit as e:
|
||||
state["args"] = getattr(parser, "message", None) or e
|
||||
state["args"] = e
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user