aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/tools/console
diff options
context:
space:
mode:
Diffstat (limited to 'mitmproxy/tools/console')
-rw-r--r--mitmproxy/tools/console/commander/commander.py8
-rw-r--r--mitmproxy/tools/console/commands.py2
-rw-r--r--mitmproxy/tools/console/consoleaddons.py11
3 files changed, 11 insertions, 10 deletions
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py
index f826b984..d751422b 100644
--- a/mitmproxy/tools/console/commander/commander.py
+++ b/mitmproxy/tools/console/commander/commander.py
@@ -14,7 +14,7 @@ import mitmproxy.types
class Completer:
@abc.abstractmethod
- def cycle(self, forward: bool) -> str:
+ def cycle(self, forward: bool = True) -> str:
raise NotImplementedError()
@@ -32,7 +32,7 @@ class ListCompleter(Completer):
self.options.sort()
self.offset = 0
- def cycle(self, forward: bool) -> str:
+ def cycle(self, forward: bool = True) -> str:
if not self.options:
return self.start
ret = self.options[self.offset]
@@ -98,7 +98,7 @@ class CommandBuffer:
def right(self) -> None:
self.cursor = self.cursor + 1
- def cycle_completion(self, forward: bool) -> None:
+ def cycle_completion(self, forward: bool = True) -> None:
if not self.completion:
parts, remaining = self.master.commands.parse_partial(self.text[:self.cursor])
if parts and parts[-1].type != mitmproxy.types.Space:
@@ -211,7 +211,7 @@ class CommandEdit(urwid.WidgetWrap):
elif key == "shift tab":
self.cbuf.cycle_completion(False)
elif key == "tab":
- self.cbuf.cycle_completion(True)
+ self.cbuf.cycle_completion()
elif len(key) == 1:
self.cbuf.insert(key)
self.update()
diff --git a/mitmproxy/tools/console/commands.py b/mitmproxy/tools/console/commands.py
index d35a6b8a..26a99b14 100644
--- a/mitmproxy/tools/console/commands.py
+++ b/mitmproxy/tools/console/commands.py
@@ -25,7 +25,7 @@ class CommandItem(urwid.WidgetWrap):
if self.cmd.parameters:
parts += [
("text", " "),
- ("text", " ".join(name for name, t in self.cmd.parameters)),
+ ("text", " ".join(str(param) for param in self.cmd.parameters)),
]
if self.cmd.return_type:
parts += [
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index b5263f6f..4288696a 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -287,21 +287,22 @@ class ConsoleAddon:
)
@command.command("console.command")
- def console_command(self, *cmdstr: str) -> None:
+ def console_command(self, *cmd_str: str) -> None:
"""
Prompt the user to edit a command with a (possibly empty) starting value.
"""
- signals.status_prompt_command.send(partial=" ".join(cmdstr)) # type: ignore
+ cmd_str = (command.quote(x) if x else "" for x in cmd_str)
+ signals.status_prompt_command.send(partial=" ".join(cmd_str)) # type: ignore
@command.command("console.command.set")
def console_command_set(self, option_name: str) -> None:
"""
- Prompt the user to set an option of the form "key[=value]".
+ Prompt the user to set an option.
"""
option_value = getattr(self.master.options, option_name, None)
- current_value = option_value if option_value else ""
+ option_value = command.quote(option_value)
self.master.commands.execute(
- "console.command set %s=%s" % (option_name, current_value)
+ f"console.command set {option_name} {option_value}"
)
@command.command("console.view.keybindings")