mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-11-04 00:46:43 +00:00 
			
		
		
		
	💡 update docstring
This commit is contained in:
		@@ -12,6 +12,7 @@
 | 
				
			|||||||
- ``on_endswith`` => ``nonebot.plugin.on_endswith``
 | 
					- ``on_endswith`` => ``nonebot.plugin.on_endswith``
 | 
				
			||||||
- ``on_keyword`` => ``nonebot.plugin.on_keyword``
 | 
					- ``on_keyword`` => ``nonebot.plugin.on_keyword``
 | 
				
			||||||
- ``on_command`` => ``nonebot.plugin.on_command``
 | 
					- ``on_command`` => ``nonebot.plugin.on_command``
 | 
				
			||||||
 | 
					- ``on_shell_command`` => ``nonebot.plugin.on_shell_command``
 | 
				
			||||||
- ``on_regex`` => ``nonebot.plugin.on_regex``
 | 
					- ``on_regex`` => ``nonebot.plugin.on_regex``
 | 
				
			||||||
- ``CommandGroup`` => ``nonebot.plugin.CommandGroup``
 | 
					- ``CommandGroup`` => ``nonebot.plugin.CommandGroup``
 | 
				
			||||||
- ``Matchergroup`` => ``nonebot.plugin.MatcherGroup``
 | 
					- ``Matchergroup`` => ``nonebot.plugin.MatcherGroup``
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -280,6 +280,11 @@ def command(*cmds: Union[str, Tuple[str, ...]]) -> Rule:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ArgumentParser(ArgParser):
 | 
					class ArgumentParser(ArgParser):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    :说明:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ``shell_like`` 命令参数解析器,解析出错时不会退出程序。
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _print_message(self, message, file=None):
 | 
					    def _print_message(self, message, file=None):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
@@ -287,16 +292,11 @@ class ArgumentParser(ArgParser):
 | 
				
			|||||||
    def exit(self, status=0, message=None):
 | 
					    def exit(self, status=0, message=None):
 | 
				
			||||||
        raise ParserExit(status=status, message=message)
 | 
					        raise ParserExit(status=status, message=message)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def parse_args(
 | 
					    def parse_args(self,
 | 
				
			||||||
            self,
 | 
					                   args: Optional[Sequence[str]] = None,
 | 
				
			||||||
            args: Optional[Sequence[str]] = None,
 | 
					                   namespace: Optional[Namespace] = None) -> Namespace:
 | 
				
			||||||
            namespace: Optional[Namespace] = None
 | 
					        return super().parse_args(args=args,
 | 
				
			||||||
    ) -> Union[ParserExit, Namespace]:
 | 
					                                  namespace=namespace)  # type: ignore
 | 
				
			||||||
        try:
 | 
					 | 
				
			||||||
            return super().parse_args(args=args,
 | 
					 | 
				
			||||||
                                      namespace=namespace)  # type: ignore
 | 
					 | 
				
			||||||
        except ParserExit as e:
 | 
					 | 
				
			||||||
            return e
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def shell_command(*cmds: Union[str, Tuple[str, ...]],
 | 
					def shell_command(*cmds: Union[str, Tuple[str, ...]],
 | 
				
			||||||
@@ -361,8 +361,11 @@ def shell_command(*cmds: Union[str, Tuple[str, ...]],
 | 
				
			|||||||
                                       ):].lstrip()
 | 
					                                       ):].lstrip()
 | 
				
			||||||
            state["argv"] = shlex.split(strip_message)
 | 
					            state["argv"] = shlex.split(strip_message)
 | 
				
			||||||
            if parser:
 | 
					            if parser:
 | 
				
			||||||
                args = parser.parse_args(state["argv"])
 | 
					                try:
 | 
				
			||||||
                state["args"] = args
 | 
					                    args = parser.parse_args(state["argv"])
 | 
				
			||||||
 | 
					                    state["args"] = args
 | 
				
			||||||
 | 
					                except ParserExit as e:
 | 
				
			||||||
 | 
					                    state["args"] = e
 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user