diff options
Diffstat (limited to 'cmd2/command_definition.py')
-rw-r--r-- | cmd2/command_definition.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py index a63e0efc..9e7238d0 100644 --- a/cmd2/command_definition.py +++ b/cmd2/command_definition.py @@ -148,11 +148,14 @@ class CommandSet(object): :param settable: Settable object being added """ - if self._cmd and not self._cmd.always_prefix_settables: - if settable.name in self._cmd.settables.keys() and settable.name not in self._settables.keys(): - raise KeyError(f'Duplicate settable: {settable.name}') - if settable.settable_obj is None: - settable.settable_obj = self + if self._cmd: + if not self._cmd.always_prefix_settables: + if settable.name in self._cmd.settables.keys() and settable.name not in self._settables.keys(): + raise KeyError(f'Duplicate settable: {settable.name}') + else: + prefixed_name = f'{self._settable_prefix}.{settable.name}' + if prefixed_name in self._cmd.settables.keys() and settable.name not in self._settables.keys(): + raise KeyError(f'Duplicate settable: {settable.name}') self._settables[settable.name] = settable def remove_settable(self, name: str) -> None: |