Skip to content

Commit 2fbe90b

Browse files
committed
Clean up regex arity of help fn
1 parent fd3e7c7 commit 2fbe90b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

goal.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,12 @@ func helpMonadic(help Help, args []goal.V) goal.V {
115115
panic(`Developer Error: Help dictionary should have a "goal" entry.`)
116116
}
117117
for binding, helpString := range goalHelpMap {
118-
if (regex.MatchString(binding) || regex.MatchString(helpString)) && !isGeneralHelpEntry(binding) {
118+
if !isGeneralHelpEntry(binding) && (regex.MatchString(binding) || regex.MatchString(helpString)) {
119119
fmt.Fprintln(os.Stdout, strings.TrimSpace(help.Func(binding)))
120120
}
121121
}
122-
// TODO Search by regular expression
123122
default:
124-
return goal.Panicf("help x : x not a string (%s)", x.Type())
123+
return goal.Panicf("help x : x must be a string or regex, received a %q: %v", x.Type(), x)
125124
}
126125
return goal.NewI(1)
127126
}
@@ -141,14 +140,11 @@ func helpDyadic(help Help, args []goal.V) goal.V {
141140
return goal.NewI(1)
142141
}
143142

144-
// These are Goal's help entries that cover topic areas. We do not want to match on these for regex help matching,
145-
// as it makes the output too noisy.
146-
var generalHelpEntries = []string{
147-
"s", "t", "v", "nv", "a", "tm", "rt", "io",
148-
}
149-
143+
// We do not want to match on these help topics for regex help matching, as it makes the output too noisy.
150144
func isGeneralHelpEntry(entry string) bool {
151-
return slices.Contains(generalHelpEntries, entry)
145+
return slices.Contains([]string{
146+
"s", "t", "v", "nv", "a", "tm", "rt", "io",
147+
}, entry)
152148
}
153149

154150
// Go <> Goal helpers

0 commit comments

Comments
 (0)