aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-08-01 08:41:57 +0800
committerMatthew Shao <me@matshao.com>2017-08-01 08:41:57 +0800
commit2aa97c9b75989e20faf475fed5da1363e8bed87b (patch)
tree0177c9a854e709e75574afddfc57d3f9c1ad40d3
parentd02c825427a6df8fc2bc9a6f5b5b12228a230b3e (diff)
downloadmitmproxy-2aa97c9b75989e20faf475fed5da1363e8bed87b.tar.gz
mitmproxy-2aa97c9b75989e20faf475fed5da1363e8bed87b.tar.bz2
mitmproxy-2aa97c9b75989e20faf475fed5da1363e8bed87b.zip
Move console-relatived options into their own addons.
-rw-r--r--mitmproxy/options.py60
-rw-r--r--mitmproxy/tools/console/consoleaddons.py60
2 files changed, 60 insertions, 60 deletions
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index 20151c19..87318919 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -4,29 +4,6 @@ from mitmproxy import optmanager
from mitmproxy import contentviews
from mitmproxy.net import tcp
-# We redefine these here for now to avoid importing Urwid-related guff on
-# platforms that don't support it, and circular imports. We can do better using
-# a lazy checker down the track.
-console_palettes = [
- "lowlight",
- "lowdark",
- "light",
- "dark",
- "solarized_light",
- "solarized_dark"
-]
-view_orders = [
- "time",
- "method",
- "url",
- "size",
-]
-console_layouts = [
- "single",
- "vertical",
- "horizontal",
-]
-
log_verbosity = [
"error",
"warn",
@@ -474,43 +451,6 @@ class Options(optmanager.OptManager):
"Intercept filter expression."
)
- # Console options
- self.add_option(
- "console_layout", str, "single",
- "Console layout.",
- choices=sorted(console_layouts),
- )
- self.add_option(
- "console_layout_headers", bool, True,
- "Show layout comonent headers",
- )
- self.add_option(
- "console_focus_follow", bool, False,
- "Focus follows new flows."
- )
- self.add_option(
- "console_palette", str, "solarized_dark",
- "Color palette.",
- choices=sorted(console_palettes),
- )
- self.add_option(
- "console_palette_transparent", bool, False,
- "Set transparent background for palette."
- )
- self.add_option(
- "console_mouse", bool, True,
- "Console mouse interaction."
- )
- self.add_option(
- "console_order", str, "time",
- "Flow sort order.",
- choices=view_orders,
- )
- self.add_option(
- "console_order_reversed", bool, False,
- "Reverse the sorting order."
- )
-
self.add_option(
"view_filter", Optional[str], None,
"Limit which flows are displayed."
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index 0b0993c8..f561f61e 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -11,6 +11,29 @@ from mitmproxy.tools.console import overlay
from mitmproxy.tools.console import signals
from mitmproxy.tools.console import keymap
+# We redefine these here for now to avoid importing Urwid-related guff on
+# platforms that don't support it, and circular imports. We can do better using
+# a lazy checker down the track.
+console_palettes = [
+ "lowlight",
+ "lowdark",
+ "light",
+ "dark",
+ "solarized_light",
+ "solarized_dark"
+]
+view_orders = [
+ "time",
+ "method",
+ "url",
+ "size",
+]
+console_layouts = [
+ "single",
+ "vertical",
+ "horizontal",
+]
+
class Logger:
def log(self, evt):
@@ -60,6 +83,43 @@ class ConsoleAddon:
self.master = master
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."
+ )
+ loader.add_option(
+ "console_order", str, "time",
+ "Flow sort order.",
+ choices=view_orders,
+ )
+ loader.add_option(
+ "console_order_reversed", bool, False,
+ "Reverse the sorting order."
+ )
+
@command.command("console.layout.options")
def layout_options(self) -> typing.Sequence[str]:
"""