aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/tools
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-11-26 02:42:47 +0100
committerMaximilian Hils <git@maximilianhils.com>2019-11-26 02:42:47 +0100
commit06ef7350f52af34954ecde2431c34c31d177d0c7 (patch)
tree29583df93abe69c878b012277efd32faaf9b9c45 /mitmproxy/tools
parent68b016e180ec1475391f2e8389ae1c708692c499 (diff)
downloadmitmproxy-06ef7350f52af34954ecde2431c34c31d177d0c7.tar.gz
mitmproxy-06ef7350f52af34954ecde2431c34c31d177d0c7.tar.bz2
mitmproxy-06ef7350f52af34954ecde2431c34c31d177d0c7.zip
simplify command history addon
Diffstat (limited to 'mitmproxy/tools')
-rw-r--r--mitmproxy/tools/console/commander/commander.py13
-rw-r--r--mitmproxy/tools/console/statusbar.py7
2 files changed, 8 insertions, 12 deletions
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py
index ac313290..a5bd65f9 100644
--- a/mitmproxy/tools/console/commander/commander.py
+++ b/mitmproxy/tools/console/commander/commander.py
@@ -9,8 +9,6 @@ import mitmproxy.flow
import mitmproxy.master
import mitmproxy.types
-from mitmproxy import command_lexer
-
class Completer:
@abc.abstractmethod
@@ -163,7 +161,7 @@ class CommandEdit(urwid.WidgetWrap):
self.cbuf.backspace()
if self.cbuf.text == '':
self.active_filter = False
- self.master.commands.execute("command_history.filter ''")
+ self.master.commands.call("commands.history.filter", "")
self.filter_str = ''
elif key == "left":
self.cbuf.left()
@@ -173,21 +171,20 @@ class CommandEdit(urwid.WidgetWrap):
if self.active_filter is False:
self.active_filter = True
self.filter_str = self.cbuf.text
- _cmd = command_lexer.quote(self.cbuf.text)
- self.master.commands.execute("command_history.filter %s" % _cmd)
+ self.master.commands.call("commands.history.filter", self.cbuf.text)
- cmd = self.master.commands.execute("command_history.prev")
+ cmd = self.master.commands.execute("commands.history.prev")
self.cbuf = CommandBuffer(self.master, cmd)
elif key == "down":
prev_cmd = self.cbuf.text
- cmd = self.master.commands.execute("command_history.next")
+ cmd = self.master.commands.execute("commands.history.next")
if cmd == '':
if prev_cmd == self.filter_str:
self.cbuf = CommandBuffer(self.master, prev_cmd)
else:
self.active_filter = False
- self.master.commands.execute("command_history.filter ''")
+ self.master.commands.call("commands.history.filter", "")
self.filter_str = ''
self.cbuf = CommandBuffer(self.master, '')
else:
diff --git a/mitmproxy/tools/console/statusbar.py b/mitmproxy/tools/console/statusbar.py
index 39141b97..43b81d22 100644
--- a/mitmproxy/tools/console/statusbar.py
+++ b/mitmproxy/tools/console/statusbar.py
@@ -132,7 +132,6 @@ class ActionBar(urwid.WidgetWrap):
def keypress(self, size, k):
if self.prompting:
if k == "esc":
- self.master.commands.execute('command_history.cancel')
self.prompt_done()
elif self.onekey:
if k == "enter":
@@ -140,9 +139,9 @@ class ActionBar(urwid.WidgetWrap):
elif k in self.onekey:
self.prompt_execute(k)
elif k == "enter":
- cmd = command_lexer.quote(self._w.cbuf.text)
- self.master.commands.execute(f"command_history.add {cmd}")
- self.prompt_execute(self._w.get_edit_text())
+ text = self._w.get_edit_text()
+ self.prompt_execute(text)
+ self.master.commands.call("commands.history.add", text)
else:
if common.is_keypress(k):
self._w.keypress(size, k)