aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-12-30 17:37:33 +0100
committerGitHub <noreply@github.com>2017-12-30 17:37:33 +0100
commitafe6e587f9d5423cfdf3710672d3886cc2753cd6 (patch)
tree0b536f7a8e8fd8fcee5e3b95e3c63a67c2fe5af0 /mitmproxy
parent0b80fd00d458b98e700a78be1ab9a586bf45900b (diff)
parent465044c3731ac0077387f1cbb39ae4f90d3f06c8 (diff)
downloadmitmproxy-afe6e587f9d5423cfdf3710672d3886cc2753cd6.tar.gz
mitmproxy-afe6e587f9d5423cfdf3710672d3886cc2753cd6.tar.bz2
mitmproxy-afe6e587f9d5423cfdf3710672d3886cc2753cd6.zip
Merge pull request #2703 from mhils/test-defaultkeys
Test that default key bindings are valid commands
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/command.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py
index e1e56d3a..7bb2bf8e 100644
--- a/mitmproxy/command.py
+++ b/mitmproxy/command.py
@@ -76,11 +76,7 @@ class Command:
ret = " -> " + ret
return "%s %s%s" % (self.path, params, ret)
- def call(self, args: typing.Sequence[str]) -> typing.Any:
- """
- Call the command with a list of arguments. At this point, all
- arguments are strings.
- """
+ def prepare_args(self, args: typing.Sequence[str]) -> typing.List[typing.Any]:
verify_arg_signature(self.func, list(args), {})
remainder = [] # type: typing.Sequence[str]
@@ -92,6 +88,14 @@ class Command:
for arg, paramtype in zip(args, self.paramtypes):
pargs.append(parsearg(self.manager, arg, paramtype))
pargs.extend(remainder)
+ return pargs
+
+ def call(self, args: typing.Sequence[str]) -> typing.Any:
+ """
+ Call the command with a list of arguments. At this point, all
+ arguments are strings.
+ """
+ pargs = self.prepare_args(args)
with self.manager.master.handlecontext():
ret = self.func(*pargs)
@@ -121,7 +125,7 @@ ParseResult = typing.NamedTuple(
class CommandManager(mitmproxy.types._CommandBase):
def __init__(self, master):
self.master = master
- self.commands = {}
+ self.commands = {} # type: typing.Dict[str, Command]
def collect_commands(self, addon):
for i in dir(addon):