diff options
Diffstat (limited to 'docs/features')
-rw-r--r-- | docs/features/initialization.rst | 7 | ||||
-rw-r--r-- | docs/features/plugins.rst | 4 | ||||
-rw-r--r-- | docs/features/settings.rst | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/docs/features/initialization.rst b/docs/features/initialization.rst index 46b4ecd2..d48290fa 100644 --- a/docs/features/initialization.rst +++ b/docs/features/initialization.rst @@ -20,7 +20,7 @@ capabilities which you may wish to utilize while initializing the app:: """ import cmd2 from cmd2 import style - + from cmd2.ansi import FG_COLORS class BasicApp(cmd2.Cmd): CUSTOM_CATEGORY = 'My Custom Commands' @@ -48,7 +48,10 @@ capabilities which you may wish to utilize while initializing the app:: self.foreground_color = 'cyan' # Make echo_fg settable at runtime - self.settable['foreground_color'] = 'Foreground color to use with echo command' + self.add_settable(cmd2.Settable('foreground_color', + str, + 'Foreground color to use with echo command', + choices=FG_COLORS)) @cmd2.with_category(CUSTOM_CATEGORY) def do_intro(self, _): diff --git a/docs/features/plugins.rst b/docs/features/plugins.rst index caa46b8c..00c0a9f0 100644 --- a/docs/features/plugins.rst +++ b/docs/features/plugins.rst @@ -82,10 +82,10 @@ example:: super().__init__(*args, **kwargs) # code placed here runs after cmd2.Cmd initializes self.mysetting = 'somevalue' - self.settable.update({'mysetting': 'short help message for mysetting'}) + self.add_settable(cmd2.Settable('mysetting', str, 'short help message for mysetting')) You can also hide settings from the user by removing them from -``self.settable``. +``self.settables``. Decorators ~~~~~~~~~~ diff --git a/docs/features/settings.rst b/docs/features/settings.rst index 55b6a10d..6a8996e1 100644 --- a/docs/features/settings.rst +++ b/docs/features/settings.rst @@ -150,7 +150,7 @@ changes a setting, and will receive both the old value and the new value. Hide Builtin Settings ----------------------- +--------------------- You may want to prevent a user from modifying a builtin setting. A setting must appear in the :attr:`cmd2.cmd2.Cmd.settable` dictionary in order for it @@ -165,4 +165,4 @@ the :ref:`features/settings:debug` setting. To do so, remove it from the def __init__(self): super().__init__() - self.settable.pop('debug') + self.settables.pop('debug') |