aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/optmanager.py
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-06-13 23:03:07 +0800
committerMatthew Shao <me@matshao.com>2017-06-13 23:03:07 +0800
commit2c0f6c202321a9d332dbe0181d319a3be4fd2614 (patch)
tree346f0c4c9102b0c0ec6f4af4e241bc683fe7dcc5 /mitmproxy/optmanager.py
parent03bb0a09b95d1942a62435545d867b0888de75fa (diff)
downloadmitmproxy-2c0f6c202321a9d332dbe0181d319a3be4fd2614.tar.gz
mitmproxy-2c0f6c202321a9d332dbe0181d319a3be4fd2614.tar.bz2
mitmproxy-2c0f6c202321a9d332dbe0181d319a3be4fd2614.zip
Minor Update and add test.
Diffstat (limited to 'mitmproxy/optmanager.py')
-rw-r--r--mitmproxy/optmanager.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py
index 3685c003..b67949e0 100644
--- a/mitmproxy/optmanager.py
+++ b/mitmproxy/optmanager.py
@@ -420,12 +420,27 @@ def dump_dicts(opts):
"""
Dumps the options into a list of dict object.
- Return: A list like: [ { name: "anticahce", type: "bool", default: false, value: true, help: "help text"}]
+ Return: A list like: [ { name: "anticache", type: "bool", default: false, value: true, help: "help text"} ]
"""
options_list = []
for k in sorted(opts.keys()):
o = opts._options[k]
- option = {'name': k, 'type': o.typespec.__name__, 'default': o.default, 'value': o.current(), 'help': o.help.strip()}
+ if o.typespec in (str, int, bool):
+ t = o.typespec.__name__
+ elif o.typespec == typing.Optional[str]:
+ t = 'Union'
+ elif o.typespec == typing.Sequence[str]:
+ t = 'Sequence'
+ else:
+ raise NotImplementedError
+ option = {
+ 'name': k,
+ 'type': t,
+ 'default': o.default,
+ 'value': o.current(),
+ 'help': o.help,
+ 'choices': o.choices
+ }
options_list.append(option)
return options_list