Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

disable_category does not disable commands that were registered later using register_command_set #1556

Answered by kmvanbrunt
Sripadvallabh asked this question in Q&A
Discussion options

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?

You must be logged in to vote

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

Comment options

@kmvanbrunt Do you have any thoughts about this?

You must be logged in to vote
3 replies
Comment options

@kmvanbrunt any updates on this please?

Comment options

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.

Answer selected by Sripadvallabh
Comment options

Thanks @kmvanbrunt

Comment options

I just created a pull request to fix this.
#1568

You must be logged in to vote
1 reply
Comment options

@Sripadvallabh
The fix is in the 3.1.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /