diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-12-19 11:50:12 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-12-19 11:50:12 +1300 |
commit | d98fc4f03a88751944c0ae08ee2ac3e743f92952 (patch) | |
tree | 3978a872336a35c89e754e017f430d1269e234de /mitmproxy/command.py | |
parent | 843bad187cfe40c9714c6deb5170d055021a462e (diff) | |
download | mitmproxy-d98fc4f03a88751944c0ae08ee2ac3e743f92952.tar.gz mitmproxy-d98fc4f03a88751944c0ae08ee2ac3e743f92952.tar.bz2 mitmproxy-d98fc4f03a88751944c0ae08ee2ac3e743f92952.zip |
commands: partial parser now returns help for remaining arguments
Diffstat (limited to 'mitmproxy/command.py')
-rw-r--r-- | mitmproxy/command.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py index b645798d..d813568f 100644 --- a/mitmproxy/command.py +++ b/mitmproxy/command.py @@ -133,9 +133,12 @@ class CommandManager(mitmproxy.types._CommandBase): def add(self, path: str, func: typing.Callable): self.commands[path] = Command(self, path, func) - def parse_partial(self, cmdstr: str) -> typing.Sequence[ParseResult]: + def parse_partial( + self, + cmdstr: str + ) -> typing.Tuple[typing.Sequence[ParseResult], typing.Sequence[str]]: """ - Parse a possibly partial command. Return a sequence of (part, type) tuples. + Parse a possibly partial command. Return a sequence of ParseResults and a sequence of remainder type help items. """ buf = io.StringIO(cmdstr) parts = [] # type: typing.List[str] @@ -188,7 +191,16 @@ class CommandManager(mitmproxy.types._CommandBase): valid=valid, ) ) - return parse + + remhelp = [] + for x in params: + remt = mitmproxy.types.CommandTypes.get(x, None) + if not x: + remhelp = [] + break + remhelp.append(remt.display) + + return parse, remhelp def call_args(self, path: str, args: typing.Sequence[str]) -> typing.Any: """ |