mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
fix 'set' to only accept a single argument
This commit is contained in:
parent
76e6484107
commit
c7eedcbc1a
@ -83,14 +83,14 @@ class Core:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@command.command("set")
|
@command.command("set")
|
||||||
def set(self, option: str, *value: str) -> None:
|
def set(self, option: str, value: str = "") -> None:
|
||||||
"""
|
"""
|
||||||
Set an option. When the value is omitted, booleans are set to true,
|
Set an option. When the value is omitted, booleans are set to true,
|
||||||
strings and integers are set to None (if permitted), and sequences
|
strings and integers are set to None (if permitted), and sequences
|
||||||
are emptied. Boolean values can be true, false or toggle.
|
are emptied. Boolean values can be true, false or toggle.
|
||||||
Multiple values are concatenated with a single space.
|
Multiple values are concatenated with a single space.
|
||||||
"""
|
"""
|
||||||
strspec = f"{option}={' '.join(value)}"
|
strspec = f"{option}={value}"
|
||||||
try:
|
try:
|
||||||
ctx.options.set(strspec)
|
ctx.options.set(strspec)
|
||||||
except exceptions.OptionsError as e:
|
except exceptions.OptionsError as e:
|
||||||
|
@ -11,7 +11,7 @@ def test_set():
|
|||||||
sa = core.Core()
|
sa = core.Core()
|
||||||
with taddons.context(loadcore=False) as tctx:
|
with taddons.context(loadcore=False) as tctx:
|
||||||
assert tctx.master.options.server
|
assert tctx.master.options.server
|
||||||
tctx.command(sa.set, "server=false")
|
tctx.command(sa.set, "server", "false")
|
||||||
assert not tctx.master.options.server
|
assert not tctx.master.options.server
|
||||||
|
|
||||||
with pytest.raises(exceptions.CommandError):
|
with pytest.raises(exceptions.CommandError):
|
||||||
|
Loading…
Reference in New Issue
Block a user