Skip to content

Commit 6fe48a9

Browse files
committed
Checker script: Fix flag combining
- `--check` + `--svelte`, etc.
1 parent b38c552 commit 6fe48a9

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

scripts/check/main.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,49 @@ func parseFlags() *cliFlags {
129129
}
130130

131131
// selectChecks determines which checks to run based on flags.
132+
// Flags are additive: --check clippy --svelte runs clippy plus all Svelte checks.
132133
func selectChecks(flags *cliFlags) ([]checks.CheckDefinition, error) {
134+
hasFilter := len(flags.checkNames) > 0 || flags.appName != "" || flags.rustOnly || flags.svelteOnly || flags.goOnly
135+
if !hasFilter {
136+
return checks.AllChecks, nil
137+
}
138+
139+
seen := make(map[string]bool)
140+
var result []checks.CheckDefinition
141+
addUnique := func(cs []checks.CheckDefinition) {
142+
for _, c := range cs {
143+
if !seen[c.ID] {
144+
seen[c.ID] = true
145+
result = append(result, c)
146+
}
147+
}
148+
}
149+
133150
if len(flags.checkNames) > 0 {
134-
return selectChecksByID(flags.checkNames)
151+
named, err := selectChecksByID(flags.checkNames)
152+
if err != nil {
153+
return nil, err
154+
}
155+
addUnique(named)
135156
}
136157
if flags.appName != "" {
137-
return selectChecksByApp(flags.appName)
158+
byApp, err := selectChecksByApp(flags.appName)
159+
if err != nil {
160+
return nil, err
161+
}
162+
addUnique(byApp)
138163
}
139164
if flags.rustOnly {
140-
return checks.GetChecksByTech(checks.AppDesktop, "🦀 Rust"), nil
165+
addUnique(checks.GetChecksByTech(checks.AppDesktop, "🦀 Rust"))
141166
}
142167
if flags.svelteOnly {
143-
return checks.GetChecksByTech(checks.AppDesktop, "🎨 Svelte"), nil
168+
addUnique(checks.GetChecksByTech(checks.AppDesktop, "🎨 Svelte"))
144169
}
145170
if flags.goOnly {
146-
return checks.GetChecksByTech(checks.AppScripts, "🐹 Go"), nil
171+
addUnique(checks.GetChecksByTech(checks.AppScripts, "🐹 Go"))
147172
}
148-
return checks.AllChecks, nil
173+
174+
return result, nil
149175
}
150176

151177
// selectChecksByID returns checks matching the given IDs.

0 commit comments

Comments
 (0)