Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find features des...' (#71) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
All checks were successful
Security Scan / security (push) Successful in 33s

This commit is contained in:
Virgil 2026-04-02 10:38:37 +00:00
commit 76bccc0526
2 changed files with 17 additions and 15 deletions

View file

@ -71,9 +71,10 @@ func Select(label string, options []string) (string, error) {
return "", err return "", err
} }
n, err := strconv.Atoi(strings.TrimSpace(input)) trimmed := strings.TrimSpace(input)
n, err := strconv.Atoi(trimmed)
if err != nil || n < 1 || n > len(options) { if err != nil || n < 1 || n > len(options) {
return "", fmt.Errorf("invalid selection: choose a number between 1 and %d", len(options)) return "", fmt.Errorf("invalid selection %q: choose a number between 1 and %d", trimmed, len(options))
} }
return options[n-1], nil return options[n-1], nil
} }
@ -99,9 +100,10 @@ func MultiSelect(label string, options []string) ([]string, error) {
return nil, err return nil, err
} }
selected, parseErr := parseMultiSelection(strings.TrimSpace(input), len(options)) trimmed := strings.TrimSpace(input)
selected, parseErr := parseMultiSelection(trimmed, len(options))
if parseErr != nil { if parseErr != nil {
return nil, fmt.Errorf("invalid selection: %w", parseErr) return nil, fmt.Errorf("invalid selection %q: %w", trimmed, parseErr)
} }
selectedOptions := make([]string, 0, len(selected)) selectedOptions := make([]string, 0, len(selected))

View file

@ -137,7 +137,7 @@ func Confirm(prompt string, opts ...ConfirmOption) bool {
// Handle empty response // Handle empty response
if response == "" { if response == "" {
if readErr == nil && cfg.required { if readErr == nil && cfg.required {
fmt.Println("Please enter 'y' or 'n'") fmt.Println("Please enter y or n, then press Enter.")
continue continue
} }
if cfg.required { if cfg.required {
@ -156,7 +156,7 @@ func Confirm(prompt string, opts ...ConfirmOption) bool {
// Invalid response // Invalid response
if cfg.required { if cfg.required {
fmt.Println("Please enter 'y' or 'n'") fmt.Println("Please enter y or n, then press Enter.")
continue continue
} }
@ -250,7 +250,7 @@ func Question(prompt string, opts ...QuestionOption) string {
// Handle empty response // Handle empty response
if response == "" { if response == "" {
if cfg.required { if cfg.required {
fmt.Println("Please enter a value") fmt.Println("Please enter a value, then press Enter.")
continue continue
} }
response = cfg.defaultValue response = cfg.defaultValue
@ -375,10 +375,10 @@ func Choose[T any](prompt string, items []T, opts ...ChooseOption[T]) T {
return items[idx] return items[idx]
} }
if cfg.defaultN >= 0 { if cfg.defaultN >= 0 {
fmt.Printf("Default selection is not available in the current list\n") fmt.Printf("Default selection is not available in the current list. Narrow the list or choose another number.\n")
continue continue
} }
fmt.Printf("Please enter a number between 1 and %d\n", len(visible)) fmt.Printf("Please enter a number between 1 and %d.\n", len(visible))
continue continue
} }
@ -387,21 +387,21 @@ func Choose[T any](prompt string, items []T, opts ...ChooseOption[T]) T {
if n >= 1 && n <= len(visible) { if n >= 1 && n <= len(visible) {
return items[visible[n-1]] return items[visible[n-1]]
} }
fmt.Printf("Please enter a number between 1 and %d\n", len(visible)) fmt.Printf("Please enter a number between 1 and %d.\n", len(visible))
continue continue
} }
if cfg.filter { if cfg.filter {
nextVisible := filterVisible(items, visible, response, cfg.displayFn) nextVisible := filterVisible(items, visible, response, cfg.displayFn)
if len(nextVisible) == 0 { if len(nextVisible) == 0 {
fmt.Printf("No matches for %q\n", response) fmt.Printf("No matches for %q. Try a shorter search term or clear the filter.\n", response)
continue continue
} }
visible = nextVisible visible = nextVisible
continue continue
} }
fmt.Printf("Please enter a number between 1 and %d\n", len(visible)) fmt.Printf("Please enter a number between 1 and %d.\n", len(visible))
} }
} }
@ -462,7 +462,7 @@ func ChooseMulti[T any](prompt string, items []T, opts ...ChooseOption[T]) []T {
return []T{items[idx]} return []T{items[idx]}
} }
if cfg.defaultN >= 0 { if cfg.defaultN >= 0 {
fmt.Printf("Default selection is not available in the current list\n") fmt.Printf("Default selection is not available in the current list. Narrow the list or choose another number.\n")
continue continue
} }
return nil return nil
@ -474,13 +474,13 @@ func ChooseMulti[T any](prompt string, items []T, opts ...ChooseOption[T]) []T {
if cfg.filter && !looksLikeMultiSelectionInput(response) { if cfg.filter && !looksLikeMultiSelectionInput(response) {
nextVisible := filterVisible(items, visible, response, cfg.displayFn) nextVisible := filterVisible(items, visible, response, cfg.displayFn)
if len(nextVisible) == 0 { if len(nextVisible) == 0 {
fmt.Printf("No matches for %q\n", response) fmt.Printf("No matches for %q. Try a shorter search term or clear the filter.\n", response)
continue continue
} }
visible = nextVisible visible = nextVisible
continue continue
} }
fmt.Printf("Invalid selection: %v\n", err) fmt.Printf("Invalid selection %q: enter numbers like 1 3 or 1-3.\n", response)
continue continue
} }