MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / disable_category

Method disable_category

cmd2/cmd2.py:5700–5720  ·  view source on GitHub ↗

Disable an entire category of commands. :param category: the category to disable :param message_to_print: what to print when anything in this category is run or help is called on it while disabled. The variable cmd2.COMMAND_NAME can be used as a plac

(self, category: str, message_to_print: str)

Source from the content-addressed store, hash-verified

5698 setattr(self, completer_func_name, new_completer_func)
5699
5700 def disable_category(self, category: str, message_to_print: str) -> None:
5701 """Disable an entire category of commands.
5702
5703 :param category: the category to disable
5704 :param message_to_print: what to print when anything in this category is run or help is called on it
5705 while disabled. The variable cmd2.COMMAND_NAME can be used as a placeholder for the name
5706 of the command being disabled.
5707 ex: message_to_print = f"{cmd2.COMMAND_NAME} is currently disabled"
5708 """
5709 # If the category is already disabled, then return
5710 if category in self.disabled_categories:
5711 return
5712
5713 all_commands = self.get_all_commands()
5714
5715 for command in all_commands:
5716 command_func = cast(BoundCommandFunc, self.get_command_func(command))
5717 if self._get_command_category(command_func) == category:
5718 self.disable_command(command, message_to_print)
5719
5720 self.disabled_categories[category] = message_to_print
5721
5722 def _report_disabled_command_usage(self, *_args: Any, message_to_print: str, **_kwargs: Any) -> None:
5723 """Report when a disabled command or its help function is run.

Calls 4

get_all_commandsMethod · 0.95
get_command_funcMethod · 0.95
_get_command_categoryMethod · 0.95
disable_commandMethod · 0.95