mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +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
|
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[
|
Cuts = typing.Sequence[
|
||||||
typing.Sequence[typing.Union[str, bytes]]
|
typing.Sequence[typing.Union[str, bytes]]
|
||||||
]
|
]
|
||||||
|
@ -6,6 +6,7 @@ import typing
|
|||||||
import urwid
|
import urwid
|
||||||
from urwid.text_layout import calc_coords
|
from urwid.text_layout import calc_coords
|
||||||
|
|
||||||
|
import mitmproxy.flow
|
||||||
import mitmproxy.master
|
import mitmproxy.master
|
||||||
import mitmproxy.command
|
import mitmproxy.command
|
||||||
|
|
||||||
@ -142,7 +143,14 @@ class CommandBuffer():
|
|||||||
),
|
),
|
||||||
parse = parts,
|
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:
|
if self.completion:
|
||||||
nxt = self.completion.completer.cycle()
|
nxt = self.completion.completer.cycle()
|
||||||
buf = " ".join([i.value for i in self.completion.parse[:-1]]) + " " + nxt
|
buf = " ".join([i.value for i in self.completion.parse[:-1]]) + " " + nxt
|
||||||
|
Loading…
Reference in New Issue
Block a user