Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#39) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Some checks are pending
Security Scan / security (push) Waiting to run
Some checks are pending
Security Scan / security (push) Waiting to run
This commit is contained in:
commit
dec7c2d14e
2 changed files with 21 additions and 2 deletions
|
|
@ -91,6 +91,22 @@ func TestChooseMulti_Good_Filter(t *testing.T) {
|
|||
assert.Equal(t, []string{"apple", "apricot"}, vals)
|
||||
}
|
||||
|
||||
func TestChooseMulti_Good_Commas(t *testing.T) {
|
||||
SetStdin(strings.NewReader("1,3\n"))
|
||||
defer SetStdin(nil)
|
||||
|
||||
vals := ChooseMulti("Pick", []string{"a", "b", "c"})
|
||||
assert.Equal(t, []string{"a", "c"}, vals)
|
||||
}
|
||||
|
||||
func TestChooseMulti_Good_CommasAndRanges(t *testing.T) {
|
||||
SetStdin(strings.NewReader("1-2,4\n"))
|
||||
defer SetStdin(nil)
|
||||
|
||||
vals := ChooseMulti("Pick", []string{"a", "b", "c", "d"})
|
||||
assert.Equal(t, []string{"a", "b", "d"}, vals)
|
||||
}
|
||||
|
||||
func TestSetStdin_Good_ResetNil(t *testing.T) {
|
||||
original := stdin
|
||||
t.Cleanup(func() { stdin = original })
|
||||
|
|
|
|||
|
|
@ -503,12 +503,15 @@ func looksLikeMultiSelectionInput(input string) bool {
|
|||
return hasDigit
|
||||
}
|
||||
|
||||
// parseMultiSelection parses a multi-selection string like "1 3 5" or "1-3 5".
|
||||
// parseMultiSelection parses a multi-selection string like "1 3 5", "1,3,5",
|
||||
// or "1-3 5".
|
||||
// Returns 0-based indices.
|
||||
func parseMultiSelection(input string, maxItems int) ([]int, error) {
|
||||
selected := make(map[int]bool)
|
||||
|
||||
for part := range strings.FieldsSeq(input) {
|
||||
normalized := strings.NewReplacer(",", " ").Replace(input)
|
||||
|
||||
for part := range strings.FieldsSeq(normalized) {
|
||||
// Check for range (e.g., "1-3")
|
||||
if strings.Contains(part, "-") {
|
||||
var rangeParts []string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue