MCPcopy Create free account
hub / github.com/diillson/chatcli / askSessionChoice

Function askSessionChoice

cli/cli_session.go:58–72  ·  view source on GitHub ↗

askSessionChoice displays an interactive prompt with the given options and returns the user's choice. options is a list of i18n keys to display; validChoices maps single-char inputs to return values.

(optionKeys []string, validChoices map[string]string, defaultChoice string)

Source from the content-addressed store, hash-verified

56// askSessionChoice displays an interactive prompt with the given options and returns the user's choice.
57// options is a list of i18n keys to display; validChoices maps single-char inputs to return values.
58func askSessionChoice(optionKeys []string, validChoices map[string]string, defaultChoice string) string {
59 for _, key := range optionKeys {
60 fmt.Println(i18n.T(key))
61 }
62 fmt.Print(i18n.T("session.prompt_choice"))
63
64 reader := bufio.NewReader(os.Stdin)
65 input, _ := reader.ReadString('\n')
66 input = strings.TrimSpace(strings.ToLower(input))
67
68 if val, ok := validChoices[input]; ok {
69 return val
70 }
71 return defaultChoice
72}
73
74// remoteSessionCtx derives a 10-second-timeout context from the caller's
75// context for remote session operations.

Callers 3

handleSaveSessionMethod · 0.85
handleLoadSessionMethod · 0.85
handleDeleteSessionMethod · 0.85

Calls 1

TFunction · 0.92

Tested by

no test coverage detected