aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/command.py13
-rw-r--r--mitmproxy/tools/console/commander/commander.py10
-rw-r--r--mitmproxy/tools/console/consoleaddons.py6
3 files changed, 19 insertions, 10 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py
index 7374a19a..087f7770 100644
--- a/mitmproxy/command.py
+++ b/mitmproxy/command.py
@@ -17,7 +17,8 @@ from mitmproxy import flow
def lexer(s):
# mypy mis-identifies shlex.shlex as abstract
- lex = shlex.shlex(s, punctuation_chars=True) # type: ignore
+ lex = shlex.shlex(s) # type: ignore
+ lex.wordchars += "."
lex.whitespace_split = True
lex.commenters = ''
return lex
@@ -36,6 +37,10 @@ class Cmd(str):
pass
+class Arg(str):
+ pass
+
+
def typename(t: type, ret: bool) -> str:
"""
Translates a type to an explanatory string. If ret is True, we're
@@ -157,7 +162,7 @@ class CommandManager:
Parse a possibly partial command. Return a sequence of (part, type) tuples.
"""
buf = io.StringIO(cmdstr)
- parts: typing.List[str] = []
+ parts = [] # type: typing.List[str]
lex = lexer(buf)
while 1:
remainder = cmdstr[buf.tell():]
@@ -174,8 +179,8 @@ class CommandManager:
elif cmdstr.endswith(" "):
parts.append("")
- parse: typing.List[ParseResult] = []
- params: typing.List[type] = []
+ parse = [] # type: typing.List[ParseResult]
+ params = [] # type: typing.List[type]
for i in range(len(parts)):
if i == 0:
params[:] = [Cmd]
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py
index f82ce9ce..dbbc8ff2 100644
--- a/mitmproxy/tools/console/commander/commander.py
+++ b/mitmproxy/tools/console/commander/commander.py
@@ -34,9 +34,13 @@ class ListCompleter(Completer):
return ret
-class CompletionState(typing.NamedTuple):
- completer: Completer
- parse: typing.Sequence[mitmproxy.command.ParseResult]
+CompletionState = typing.NamedTuple(
+ "CompletionState",
+ [
+ ("completer", Completer),
+ ("parse", typing.Sequence[mitmproxy.command.ParseResult])
+ ]
+)
class CommandBuffer():
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index d79e3947..023cc5d9 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -228,7 +228,7 @@ class ConsoleAddon:
prompt: str,
choices: typing.Sequence[str],
cmd: command.Cmd,
- *args: str,
+ *args: command.Arg
) -> None:
"""
Prompt the user to choose from a specified list of strings, then
@@ -250,7 +250,7 @@ class ConsoleAddon:
@command.command("console.choose.cmd")
def console_choose_cmd(
- self, prompt: str, choicecmd: command.Cmd, *cmd: str
+ self, prompt: str, choicecmd: command.Cmd, *cmd: command.Arg
) -> None:
"""
Prompt the user to choose from a list of strings returned by a
@@ -501,7 +501,7 @@ class ConsoleAddon:
contexts: typing.Sequence[str],
key: str,
cmd: command.Cmd,
- *args: str,
+ *args: command.Arg
) -> None:
"""
Bind a shortcut key.