diff options
Diffstat (limited to 'internal/repl')
| -rw-r--r-- | internal/repl/completer.go | 17 | ||||
| -rw-r--r-- | internal/repl/repl.go | 10 |
2 files changed, 10 insertions, 17 deletions
diff --git a/internal/repl/completer.go b/internal/repl/completer.go index e9387fd..3f55212 100644 --- a/internal/repl/completer.go +++ b/internal/repl/completer.go @@ -50,20 +50,3 @@ func completer(d prompt.Document) []prompt.Suggest { } return suggestions } - -// getCommandDescription returns the description for a built-in command. -// It's used by the completer function to provide helpful descriptions during tab-completion. -// -// cmd: the built-in command name (e.g., "help", "clear", "quit") -// Returns the description string for the command, or empty string if not found -func getCommandDescription(cmd string) string { - descriptions := map[string]string{ - "help": "Show help information", - "clear": "Clear the screen", - "quit": "Exit the REPL", - "exit": "Exit the REPL", - "rpn": "Evaluate an RPN (postfix notation) expression", - "calc": "Same as rpn - evaluate an RPN expression", - } - return descriptions[cmd] -} diff --git a/internal/repl/repl.go b/internal/repl/repl.go index 905b390..950156b 100644 --- a/internal/repl/repl.go +++ b/internal/repl/repl.go @@ -182,6 +182,16 @@ func defaultCompleter(r *REPL, d prompt.Document) []prompt.Suggest { // cmd: the built-in command name (e.g., "help", "clear", "quit") // Returns the description string for the command, or empty string if not found func (r *REPL) defaultGetCommandDescription(cmd string) string { + return getCommandDescription(cmd) +} + +// getCommandDescription returns the description for a built-in command. +// This is a package-level function that provides a single source of truth +// for command descriptions, used by defaultGetCommandDescription. +// +// cmd: the built-in command name (e.g., "help", "clear", "quit") +// Returns the description string for the command, or empty string if not found +func getCommandDescription(cmd string) string { descriptions := map[string]string{ "help": "Show help information", "clear": "Clear the screen", |
