Skip to content

Commit 1c416b0

Browse files
committed
test: handle arg entries in surface parser
1 parent 4daab31 commit 1c416b0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

internal/commands/surface_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55
"path/filepath"
66
"runtime"
7+
"strconv"
78
"strings"
89
"testing"
910

@@ -112,6 +113,20 @@ func parseSurfaceEntries(s string) []surface.Entry {
112113
path := strings.Join(subParts[:len(subParts)-1], " ")
113114
entries = append(entries, surface.Entry{Kind: kind, Path: path, Name: name})
114115
}
116+
case surface.KindArg:
117+
argParts := strings.Fields(rest)
118+
if len(argParts) >= 3 {
119+
path := strings.Join(argParts[:len(argParts)-2], " ")
120+
nameSpec := argParts[len(argParts)-1]
121+
entry := surface.Entry{Kind: kind, Path: path, Name: strings.Trim(nameSpec, "[]<>")}
122+
if pos, err := strconv.Atoi(argParts[len(argParts)-2]); err == nil {
123+
entry.Position = pos
124+
}
125+
entry.Required = strings.HasPrefix(nameSpec, "<")
126+
entry.Variadic = strings.HasSuffix(nameSpec, "...]") || strings.HasSuffix(nameSpec, "...>")
127+
entry.Name = strings.TrimSuffix(entry.Name, "...")
128+
entries = append(entries, entry)
129+
}
115130
}
116131
}
117132
return entries

0 commit comments

Comments
 (0)