diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-12-17 11:23:20 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-17 11:23:20 +1300 |
commit | 1f6656ccb1e75822a84a8802b9bcbeb43709ba04 (patch) | |
tree | e3d2078d88d7184e6d7f23b6db4d29b5a417dfa7 | |
parent | 49142883e870ea7af440037c870d0885e82b6554 (diff) | |
parent | e549b63465253a8b4cdb17efbf130e20371aa3b0 (diff) | |
download | mitmproxy-1f6656ccb1e75822a84a8802b9bcbeb43709ba04.tar.gz mitmproxy-1f6656ccb1e75822a84a8802b9bcbeb43709ba04.tar.bz2 mitmproxy-1f6656ccb1e75822a84a8802b9bcbeb43709ba04.zip |
Merge pull request #2686 from cortesi/flowspecopts
commander: add completion for flowspecs
-rw-r--r-- | mitmproxy/command.py | 26 | ||||
-rw-r--r-- | mitmproxy/tools/console/commander/commander.py | 10 |
2 files changed, 35 insertions, 1 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py index 2d51317c..22c2376b 100644 --- a/mitmproxy/command.py +++ b/mitmproxy/command.py @@ -24,6 +24,32 @@ def lexer(s): return lex +# This is an awkward location for these values, but it's better than having +# the console core import and depend on an addon. FIXME: Add a way for +# addons to add custom types and manage their completion and validation. +valid_flow_prefixes = [ + "@all", + "@focus", + "@shown", + "@hidden", + "@marked", + "@unmarked", + "~q", + "~s", + "~a", + "~hq", + "~hs", + "~b", + "~bq", + "~bs", + "~t", + "~d", + "~m", + "~u", + "~c", +] + + Cuts = typing.Sequence[ typing.Sequence[typing.Union[str, bytes]] ] diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py index b94d6f69..ef32b953 100644 --- a/mitmproxy/tools/console/commander/commander.py +++ b/mitmproxy/tools/console/commander/commander.py @@ -6,6 +6,7 @@ import typing import urwid from urwid.text_layout import calc_coords +import mitmproxy.flow import mitmproxy.master import mitmproxy.command @@ -142,7 +143,14 @@ class CommandBuffer(): ), parse = parts, ) - + elif last.type in (typing.Sequence[mitmproxy.flow.Flow], mitmproxy.flow.Flow): + self.completion = CompletionState( + completer = ListCompleter( + "", + mitmproxy.command.valid_flow_prefixes, + ), + parse = parts, + ) if self.completion: nxt = self.completion.completer.cycle() buf = " ".join([i.value for i in self.completion.parse[:-1]]) + " " + nxt |