aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-08-04 10:59:42 +0800
committerMatthew Shao <me@matshao.com>2017-08-04 10:59:42 +0800
commitca2126b385d08d636b87432d4224389f91a47075 (patch)
treeb9b6192d090006eae44e9dd998b07b80e0a12095
parentb42f5bcb9dd6a8d2609b8351f846a654a1fd65c2 (diff)
downloadmitmproxy-ca2126b385d08d636b87432d4224389f91a47075.tar.gz
mitmproxy-ca2126b385d08d636b87432d4224389f91a47075.tar.bz2
mitmproxy-ca2126b385d08d636b87432d4224389f91a47075.zip
Add consoleaddons.common_options to suggest dependency.
-rw-r--r--mitmproxy/addons/view.py3
-rw-r--r--mitmproxy/tools/console/consoleaddons.py55
-rw-r--r--mitmproxy/tools/console/eventlog.py4
3 files changed, 36 insertions, 26 deletions
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py
index 2c02b72b..b8bb42bb 100644
--- a/mitmproxy/addons/view.py
+++ b/mitmproxy/addons/view.py
@@ -23,6 +23,7 @@ from mitmproxy import connections
from mitmproxy import ctx
from mitmproxy import io
from mitmproxy import http # noqa
+from mitmproxy.tools.console import consoleaddons
# The underlying sorted list implementation expects the sort key to be stable
# for the lifetime of the object. However, if we sort by size, for instance,
@@ -146,6 +147,8 @@ class View(collections.Sequence):
self.settings = Settings(self)
def load(self, loader):
+
+ consoleaddons.common_options(loader)
loader.add_option(
"view_order", str, "time",
"Flow sort order.",
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index 87542fd4..a9903359 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -81,32 +81,7 @@ class ConsoleAddon:
self.started = False
def load(self, loader):
- loader.add_option(
- "console_layout", str, "single",
- "Console layout.",
- choices=sorted(console_layouts),
- )
- loader.add_option(
- "console_layout_headers", bool, True,
- "Show layout comonent headers",
- )
- loader.add_option(
- "console_focus_follow", bool, False,
- "Focus follows new flows."
- )
- loader.add_option(
- "console_palette", str, "solarized_dark",
- "Color palette.",
- choices=sorted(console_palettes),
- )
- loader.add_option(
- "console_palette_transparent", bool, False,
- "Set transparent background for palette."
- )
- loader.add_option(
- "console_mouse", bool, True,
- "Console mouse interaction."
- )
+ common_options(loader)
@command.command("console.layout.options")
def layout_options(self) -> typing.Sequence[str]:
@@ -553,3 +528,31 @@ class ConsoleAddon:
signals.update_settings.send(self)
for f in flows:
signals.flow_change.send(self, flow=f)
+
+def common_options(loader):
+ loader.add_option(
+ "console_layout", str, "single",
+ "Console layout.",
+ choices=sorted(console_layouts),
+ )
+ loader.add_option(
+ "console_layout_headers", bool, True,
+ "Show layout comonent headers",
+ )
+ loader.add_option(
+ "console_focus_follow", bool, False,
+ "Focus follows new flows."
+ )
+ loader.add_option(
+ "console_palette", str, "solarized_dark",
+ "Color palette.",
+ choices=sorted(console_palettes),
+ )
+ loader.add_option(
+ "console_palette_transparent", bool, False,
+ "Set transparent background for palette."
+ )
+ loader.add_option(
+ "console_mouse", bool, True,
+ "Console mouse interaction."
+ ) \ No newline at end of file
diff --git a/mitmproxy/tools/console/eventlog.py b/mitmproxy/tools/console/eventlog.py
index a76b910e..d35e24c3 100644
--- a/mitmproxy/tools/console/eventlog.py
+++ b/mitmproxy/tools/console/eventlog.py
@@ -1,6 +1,7 @@
import urwid
from mitmproxy.tools.console import signals
from mitmproxy.tools.console import layoutwidget
+from mitmproxy.tools.console import consoleaddons
from mitmproxy import ctx
from mitmproxy import log
@@ -22,6 +23,9 @@ class EventLog(urwid.ListBox, layoutwidget.LayoutWidget):
signals.sig_add_log.connect(self.sig_add_log)
signals.sig_clear_log.connect(self.sig_clear_log)
+ def load(self, loader):
+ consoleaddons.common_options(loader)
+
def set_focus(self, index):
if 0 <= index < len(self.walker):
super().set_focus(index)