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

Method _get_command_category

cmd2/cmd2.py:3345–3360  ·  view source on GitHub ↗

Determine the category for a command. :param func: the do_* function implementing the command :return: category name

(self, func: BoundCommandFunc)

Source from the content-addressed store, hash-verified

3343 return cast(BoundCommandFunc, command_func) if callable(command_func) else None
3344
3345 def _get_command_category(self, func: BoundCommandFunc) -> str:
3346 """Determine the category for a command.
3347
3348 :param func: the do_* function implementing the command
3349 :return: category name
3350 """
3351 # Check if the command function has a category.
3352 if hasattr(func, constants.CMD_ATTR_HELP_CATEGORY):
3353 category: str = getattr(func, constants.CMD_ATTR_HELP_CATEGORY)
3354
3355 # Otherwise get the category from its defining class.
3356 else:
3357 defining_cls = get_defining_class(func)
3358 category = getattr(defining_cls, "DEFAULT_CATEGORY", self.DEFAULT_CATEGORY)
3359
3360 return category
3361
3362 def onecmd(self, statement: Statement | str, *, add_to_history: bool = True) -> bool:
3363 """Execute the actual do_* method for a command.

Callers 4

register_command_setMethod · 0.95
_build_command_infoMethod · 0.95
enable_categoryMethod · 0.95
disable_categoryMethod · 0.95

Calls 1

get_defining_classFunction · 0.85

Tested by

no test coverage detected