From d77bc35fa7df180402b86ddc1cd174b6418e019f Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Tue, 5 Mar 2024 10:07:58 -0500 Subject: [PATCH] {cli} Add "set" command to interactive mode Allows setting of logging level, trace activation, and the random number seed using the form: set [OPTION] [VALUE] Fixes #414 Fixes #415 --- modes/shell/shell.go | 127 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 3 deletions(-) diff --git a/modes/shell/shell.go b/modes/shell/shell.go index 42ec430..0d09297 100644 --- a/modes/shell/shell.go +++ b/modes/shell/shell.go @@ -5,7 +5,9 @@ import ( "errors" "fmt" "os" + "slices" "sort" + "strconv" "strings" "text/tabwriter" @@ -35,6 +37,33 @@ func (e ErrUnrecognizedCommand) Error() string { return fmt.Sprintf("unrecognized command: %q", e.Command) } +type ErrInvalidSetCommand struct { + Command string +} + +func (e ErrInvalidSetCommand) Error() string { + return fmt.Sprintf("invalid set command: %q; expected form `set