summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-02-05 11:38:06 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-02-05 11:39:50 -0500
commit7519f742923a31599c56dfc5db9aad6901bfce73 (patch)
tree8d99bca4a0effbda93537e58ef3da70a5f281494 /cmd2/cmd2.py
parent34f00eda97d44922896beac608a9d4a085ae6e0d (diff)
downloadcmd2-git-7519f742923a31599c56dfc5db9aad6901bfce73.tar.gz
Added remove_settable() since cmd2 has add_settable()
Documented Settable.onchange_cb
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 37779f56..7373188b 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -388,6 +388,17 @@ class Cmd(cmd.Cmd):
"""
self.settables[settable.name] = settable
+ def remove_settable(self, name: str) -> None:
+ """
+ Convenience method for removing a settable parameter from self.settables
+ :param name: name of the settable being removed
+ :raises: KeyError if the no Settable matches this name
+ """
+ try:
+ del self.settables[name]
+ except KeyError:
+ raise KeyError(name + " is not a settable parameter")
+
def build_settables(self):
"""Populates self.add_settable with parameters that can be edited via the set command"""
self.add_settable(Settable('allow_style', str,