diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-04-28 10:41:44 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-04-28 10:41:44 +1200 |
commit | 8a07059cf43104636f8f6c6f52854da66a9b9ea8 (patch) | |
tree | 0b968a9e6f9be45604e94d0939c519bf6866552a /mitmproxy/addons/core.py | |
parent | be1b76b975ea6f9510a44cc3314414043c9364c6 (diff) | |
download | mitmproxy-8a07059cf43104636f8f6c6f52854da66a9b9ea8.tar.gz mitmproxy-8a07059cf43104636f8f6c6f52854da66a9b9ea8.tar.bz2 mitmproxy-8a07059cf43104636f8f6c6f52854da66a9b9ea8.zip |
commands: add the core command addon, and the command "set"
The set command sets an option using the same syntax as commandline --set.
Diffstat (limited to 'mitmproxy/addons/core.py')
-rw-r--r-- | mitmproxy/addons/core.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mitmproxy/addons/core.py b/mitmproxy/addons/core.py new file mode 100644 index 00000000..7b648403 --- /dev/null +++ b/mitmproxy/addons/core.py @@ -0,0 +1,18 @@ +from mitmproxy import ctx +from mitmproxy import exceptions + + +class Core: + def set(self, spec: str) -> None: + """ + Set an option of the form "key[=value]". When the value is omitted, + booleans are set to true, strings and integers are set to None (if + permitted), and sequences are emptied. + """ + try: + ctx.options.set(spec) + except exceptions.OptionsError as e: + raise exceptions.CommandError(e) from e + + def load(self, l): + l.add_command("set", self.set) |