From 9b95f50975ecaa8dbfd37c375ebf38e1971fc960 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Wed, 5 Feb 2020 21:00:51 -0500 Subject: Added more to onchange_cb documentation --- cmd2/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cmd2/utils.py') diff --git a/cmd2/utils.py b/cmd2/utils.py index 9635be42..2bb91ccd 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -90,9 +90,13 @@ class Settable: validation using str_to_bool(). The val_type function should raise an exception if it fails. This exception will be caught and printed by Cmd.do_set(). :param description: string describing this setting - :param onchange_cb: optional function to call when the value of this settable is altered by the set command - Callback signature: - val_changed_cb(param_name: str, old_value: Any, new_value: Any) -> Any + :param onchange_cb: optional function or method to call when the value of this settable is altered + by the set command. (e.g. onchange_cb=self.debug_changed) + + Cmd.do_set() passes the following 3 arguments to onchange_cb: + param_name: str - name of the changed parameter + old_value: Any - the value before being changed + new_value: Any - the value after being changed The following optional settings provide tab completion for a parameter's values. They correspond to the same settings in argparse-based tab completion. A maximum of one of these should be provided. -- cgit v1.2.1