diff --git a/commands/base_commands/jobs.py b/commands/base_commands/jobs.py index e244515e..81a710f0 100644 --- a/commands/base_commands/jobs.py +++ b/commands/base_commands/jobs.py @@ -8,6 +8,7 @@ database migration to add in their functionality. """ +from enum import Enum from django.conf import settings from evennia.utils.create import create_object @@ -289,6 +290,9 @@ class CmdRequest(ArxPlayerCommand): +featurerequest =<message> +prprequest <title>=<question about a player run plot> + Switches: + %s + Send a message to the GMs for help. This is usually because of wanting to take some action that requires GM intervention, such as a plot idea or some other in-game activity, but can @@ -322,6 +326,16 @@ class CmdRequest(ArxPlayerCommand): help_category = "Admin" locks = "cmd:all()" + class Switches(Enum): + followup = "<#>=<message> | Add a followup message to a request." + close = "<#>=<reason> | Close a request prematurely and provide a reason." + + switch_options = Switches.__members__ + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.format_docstring() + def display_ticket(self, ticket): """Display the ticket to the caller""" self.msg(ticket.display()) @@ -433,12 +447,13 @@ def comment_on_ticket(self): def func(self): """Implement the command""" + switches = [self.Switches[string] for string in self.switches] caller = self.caller - if "followup" in self.switches or "comment" in self.switches: + if self.Switches.followup in switches: self.comment_on_ticket() return - if "close" in self.switches: + if self.Switches.close in switches: self.close_ticket(self.lhs, self.rhs) return diff --git a/commands/mixins.py b/commands/mixins.py index 1b5d8eba..c2e84e32 100644 --- a/commands/mixins.py +++ b/commands/mixins.py @@ -12,6 +12,11 @@ class ArxCommmandMixin(object): error_class = CommandError help_entry_tags = [] + def format_docstring(self): + self.__doc__ = self.__doc__ % "%r ".join( + f"{switch.name} {switch.value}" for switch in self.switch_options + ) + def fail(self, msg): """Raises an error for the class with a given message""" raise self.error_class(msg)