From 2aa97c9b75989e20faf475fed5da1363e8bed87b Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Tue, 1 Aug 2017 08:41:57 +0800 Subject: [PATCH] Move console-relatived options into their own addons. --- mitmproxy/options.py | 60 ------------------------ mitmproxy/tools/console/consoleaddons.py | 60 ++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 20151c194..87318919f 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 0b0993c8a..f561f61ec 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]: """