diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 75860e976c..a1ec71caf0 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -780,13 +780,14 @@ class CmdSetHelp(CmdHelp): Edit the help database. Usage: - sethelp[/switches] [[;alias;alias][,category[,locks]] [= ] - + sethelp[/switches] [[;alias;alias][,category[,locks]] + [= ] Switches: edit - open a line editor to edit the topic's help text. replace - overwrite existing help topic. append - add text to the end of existing topic with a newline between. extend - as append, but don't add a newline. + category - change category of existing help topic. delete - remove help topic. Examples: @@ -794,6 +795,7 @@ class CmdSetHelp(CmdHelp): sethelp/append pickpocketing,Thievery = This steals ... sethelp/replace pickpocketing, ,attr(is_thief) = This steals ... sethelp/edit thievery + sethelp/category thievery = classes If not assigning a category, the `settings.DEFAULT_HELP_CATEGORY` category will be used. If no lockstring is specified, everyone will be able to read @@ -840,7 +842,7 @@ class CmdSetHelp(CmdHelp): key = "sethelp" aliases = [] - switch_options = ("edit", "replace", "append", "extend", "delete") + switch_options = ("edit", "replace", "append", "extend", "category", "delete") locks = "cmd:perm(Helper)" help_category = "Building" arg_regex = None @@ -857,7 +859,7 @@ class CmdSetHelp(CmdHelp): if not self.args: self.msg( - "Usage: sethelp[/switches] [;alias;alias][,category[,locks,..] = " + "Usage: sethelp[/switches] [[;alias;alias][,category[,locks]] [= ]" ) return @@ -986,6 +988,19 @@ class CmdSetHelp(CmdHelp): self.msg(f"Entry updated:\n{old_entry.entrytext}{aliastxt}") return + if "category" in switches: + # set the category + if not old_entry: + self.msg(f"Could not find topic '{topicstr}'{aliastxt}.") + return + if not self.rhs: + self.msg("You must supply a category.") + return + category = self.rhs.lower() + old_entry.help_category = category + self.msg(f"Category for entry '{topicstr}'{aliastxt} changed to '{category}'.") + return + if "delete" in switches or "del" in switches: # delete the help entry if not old_entry: diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 8977c890d3..3a272e04f7 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -197,6 +197,12 @@ class TestHelp(BaseEvenniaCommandTest): cmdset=CharacterCmdSet(), ) self.call(help_module.CmdHelp(), "testhelp", "Help for testhelp", cmdset=CharacterCmdSet()) + self.call( + help_module.CmdSetHelp(), + "/category testhelp = misc", + "Category for entry 'testhelp' changed to 'misc'.", + cmdset=CharacterCmdSet(), + ) @parameterized.expand( [