Move console-relatived options into their own addons.

This commit is contained in:
Matthew Shao 2017-08-01 08:41:57 +08:00
parent d02c825427
commit 2aa97c9b75
2 changed files with 60 additions and 60 deletions

View File

@ -4,29 +4,6 @@ from mitmproxy import optmanager
from mitmproxy import contentviews from mitmproxy import contentviews
from mitmproxy.net import tcp 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 = [ log_verbosity = [
"error", "error",
"warn", "warn",
@ -474,43 +451,6 @@ class Options(optmanager.OptManager):
"Intercept filter expression." "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( self.add_option(
"view_filter", Optional[str], None, "view_filter", Optional[str], None,
"Limit which flows are displayed." "Limit which flows are displayed."

View File

@ -11,6 +11,29 @@ from mitmproxy.tools.console import overlay
from mitmproxy.tools.console import signals from mitmproxy.tools.console import signals
from mitmproxy.tools.console import keymap 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: class Logger:
def log(self, evt): def log(self, evt):
@ -60,6 +83,43 @@ class ConsoleAddon:
self.master = master self.master = master
self.started = False 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") @command.command("console.layout.options")
def layout_options(self) -> typing.Sequence[str]: def layout_options(self) -> typing.Sequence[str]:
""" """