Add a prompt generator method
authorJeremy Stanley <fungi@yuggoth.org>
Sun, 5 May 2019 16:20:48 +0000 (16:20 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Sun, 5 May 2019 16:20:48 +0000 (16:20 +0000)
Move the retrieval and assembly of the prompt string fragment for
active state users into its own method, paving the way for more
dynamic and extensible prompts.

mudpy/misc.py

index 0e7e561..b4009c9 100644 (file)
@@ -661,6 +661,10 @@ class User:
             self.error = False
             self.adjust_echoing()
 
+    def prompt(self):
+        """"Generate and return an input prompt."""
+        return self.account.get("prompt", ">") + " "
+
     def adjust_echoing(self):
         """Adjust echoing to match state menu requirements."""
         if mudpy.telnet.is_enabled(self, mudpy.telnet.TELOPT_ECHO,
@@ -723,7 +727,7 @@ class User:
                 if not just_prompt:
                     output += "$(eol)"
                 if add_prompt:
-                    output += self.account.get("prompt", ">") + " "
+                    output += self.prompt()
                     mode = self.avatar.get("mode")
                     if mode:
                         output += "(" + mode + ") "