From 582e6a9fa62eeba05561ba2105bf7c8a73211b4d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 15 Dec 2017 14:33:05 +1300 Subject: command: recursive command parsing This lets us complete commands passed to commands correctly. --- test/mitmproxy/test_command.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 76ce2245..298b34fb 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -24,6 +24,10 @@ class TAddon: def cmd3(self, foo: int) -> int: return foo + @command.command("subcommand") + def subcommand(self, cmd: command.Cmd, *args: command.Arg) -> str: + return "ok" + @command.command("empty") def empty(self) -> None: pass @@ -102,6 +106,21 @@ class TestCommand: command.ParseResult(value = "", type = int), ] ], + [ + "subcommand ", + [ + command.ParseResult(value = "subcommand", type = command.Cmd), + command.ParseResult(value = "", type = command.Cmd), + ] + ], + [ + "subcommand cmd3 ", + [ + command.ParseResult(value = "subcommand", type = command.Cmd), + command.ParseResult(value = "cmd3", type = command.Cmd), + command.ParseResult(value = "", type = int), + ] + ], ] with taddons.context() as tctx: tctx.master.addons.add(TAddon()) -- cgit v1.2.3