aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2017-12-15 14:33:05 +1300
committerAldo Cortesi <aldo@nullcube.com>2017-12-15 16:02:34 +1300
commit582e6a9fa62eeba05561ba2105bf7c8a73211b4d (patch)
treec16132917e956cc2a12821302fa8089dabc1aa6f /test
parenta436af537abfbccf45e5f8775dc717dff3ba9a86 (diff)
downloadmitmproxy-582e6a9fa62eeba05561ba2105bf7c8a73211b4d.tar.gz
mitmproxy-582e6a9fa62eeba05561ba2105bf7c8a73211b4d.tar.bz2
mitmproxy-582e6a9fa62eeba05561ba2105bf7c8a73211b4d.zip
command: recursive command parsing
This lets us complete commands passed to commands correctly.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_command.py19
1 files changed, 19 insertions, 0 deletions
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())