mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Merge pull request #2686 from cortesi/flowspecopts
commander: add completion for flowspecs
This commit is contained in:
commit
1f6656ccb1
@ -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]]
|
||||
]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user