-
Notifications
You must be signed in to change notification settings - Fork 128
disable_category does not disable commands that were registered later using register_command_set
#1556
-
I know this is not much of a concern, but i saw this happening in my code:
class MyCmd2App(cmd2.Cmd): def __init__(self) -> None: super().__init__() ... self.disable_category("VI. MyCategory", "Enable by ...") ... self.register_command_set(MyCommandSet(self.dependency1)) cmd2.categorize((do_xxx), "VI. MyCategory")
Now, on command xxx we get the "Enable by ..." error message, but the command in MyCommandSet works & shows up in '?' as well.
Is this the expected behaviour or i shouldn't be adding commands to that category after disabling it? I see on decorator like syntax, the order is to put the category above the argparser so should the disable_category come after registration?
Beta Was this translation helpful? Give feedback.
All reactions
disable_category only disables commands which currently exist. It's basically just a wrapper around disable_command.
For now you will need to call disable_category any time a new CommandSet is registered. I'll eventually update it to be more dynamic.
These functions predate the CommandSet stuff so they were written in a way which made sense at the time.
Replies: 2 comments 4 replies
-
@kmvanbrunt Do you have any thoughts about this?
Beta Was this translation helpful? Give feedback.
All reactions
-
@kmvanbrunt any updates on this please?
Beta Was this translation helpful? Give feedback.
All reactions
-
disable_category only disables commands which currently exist. It's basically just a wrapper around disable_command.
For now you will need to call disable_category any time a new CommandSet is registered. I'll eventually update it to be more dynamic.
These functions predate the CommandSet stuff so they were written in a way which made sense at the time.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks @kmvanbrunt
Beta Was this translation helpful? Give feedback.
All reactions
-
I just created a pull request to fix this.
#1568
Beta Was this translation helpful? Give feedback.
All reactions
-
@Sripadvallabh
The fix is in the 3.1.3 release.
Beta Was this translation helpful? Give feedback.