@@ -93,6 +93,17 @@ func (opts *ShellOptions) Show(key string) (bool, string) {
9393 }
9494}
9595
96+ // ShowConfig shows a config value from the shell controller
97+ func (sc * ShellController ) ShowConfig (key string ) (bool , string ) {
98+ switch key {
99+ case "ttable-mem-fraction" :
100+ val := sc .config .GetFloat64 (config .ConfigTtableMemFraction )
101+ return true , fmt .Sprintf ("%.2f (%.0f%% of memory)" , val , val * 100 )
102+ default :
103+ return false , "No such config option: " + key
104+ }
105+ }
106+
96107func (opts * ShellOptions ) ToDisplayText () string {
97108 keys := []string {"lexicon" , "challenge" , "lower" , "board" }
98109 out := strings.Builder {}
@@ -105,6 +116,21 @@ func (opts *ShellOptions) ToDisplayText() string {
105116 return out .String ()
106117}
107118
119+ // ToDisplayTextWithConfig includes both options and config settings
120+ func (sc * ShellController ) ToDisplayTextWithConfig () string {
121+ out := strings.Builder {}
122+ out .WriteString (sc .options .ToDisplayText ())
123+
124+ // Add config settings
125+ configKeys := []string {"ttable-mem-fraction" }
126+ for _ , key := range configKeys {
127+ _ , val := sc .ShowConfig (key )
128+ out .WriteString (" " + key + ": " )
129+ out .WriteString (val + "\n " )
130+ }
131+ return out .String ()
132+ }
133+
108134// VariationNode represents a position in the variation tree.
109135// The tree structure allows exploring different move sequences from the same position.
110136type VariationNode struct {
@@ -367,6 +393,21 @@ func (sc *ShellController) Set(key string, args []string) (string, error) {
367393 } else {
368394 err = errors .New ("Valid options: 'true', 'false'" )
369395 }
396+ case "ttable-mem-fraction" :
397+ val , err := strconv .ParseFloat (args [0 ], 64 )
398+ if err != nil {
399+ err = errors .New ("ttable-mem-fraction must be a number between 0 and 1" )
400+ } else if val <= 0 || val > 1 {
401+ err = errors .New ("ttable-mem-fraction must be between 0 and 1 (e.g., 0.25 for 25% of memory)" )
402+ } else {
403+ sc .config .Set (config .ConfigTtableMemFraction , val )
404+ err = sc .config .Write ()
405+ if err != nil {
406+ log .Err (err ).Msg ("error-writing-config" )
407+ } else {
408+ ret = fmt .Sprintf ("%.2f (%.0f%% of memory)" , val , val * 100 )
409+ }
410+ }
370411 default :
371412 err = errors .New ("No such option: " + key )
372413 }
0 commit comments