diff options
author | Grant Murphy <grant.murphy@elastic.co> | 2018-05-25 11:38:08 +1000 |
---|---|---|
committer | Grant Murphy <grant.murphy@elastic.co> | 2018-05-25 11:38:08 +1000 |
commit | bd7069a9e09f8c07add66576b165095acce4dea5 (patch) | |
tree | ba83f0a464537d66e829796bef7126faa6cf45f8 | |
parent | f910f361a07cc6d7efda280a698be1ac59cb1fa8 (diff) | |
download | mitmproxy-bd7069a9e09f8c07add66576b165095acce4dea5.tar.gz mitmproxy-bd7069a9e09f8c07add66576b165095acce4dea5.tar.bz2 mitmproxy-bd7069a9e09f8c07add66576b165095acce4dea5.zip |
Adjust options when changed
The existing options for the console were not being updated when a new
addon was added. This triggers the changed blinker signal when an option
is added, and also recreates self.opts when this signal is received.
Fixes #3147
-rw-r--r-- | mitmproxy/optmanager.py | 1 | ||||
-rw-r--r-- | mitmproxy/tools/console/options.py | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index a473e9df..2a4beba9 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -107,6 +107,7 @@ class OptManager: choices: typing.Optional[typing.Sequence[str]] = None ) -> None: self._options[name] = _Option(name, typespec, default, help, choices) + self.changed.send(self, updated={name}) @contextlib.contextmanager def rollback(self, updated, reraise=False): diff --git a/mitmproxy/tools/console/options.py b/mitmproxy/tools/console/options.py index 54772cf0..6e1399ce 100644 --- a/mitmproxy/tools/console/options.py +++ b/mitmproxy/tools/console/options.py @@ -106,6 +106,8 @@ class OptionListWalker(urwid.ListWalker): self.master.options.changed.connect(self.sig_mod) def sig_mod(self, *args, **kwargs): + self.opts = sorted(self.master.options.keys()) + self.maxlen = max(len(i) for i in self.opts) self._modified() self.set_focus(self.index) |