Capture and validate invocation features
This commit is contained in:
10
command.go
10
command.go
@@ -71,6 +71,7 @@ type commandRecord struct {
|
||||
summary string
|
||||
description string
|
||||
children []Command
|
||||
features []InvocationFeature
|
||||
payload commandPayload
|
||||
issues []error
|
||||
rootOnly bool
|
||||
@@ -467,6 +468,15 @@ func validateCommandPlacement(command Command) error {
|
||||
issues = append(issues, issue)
|
||||
}
|
||||
}
|
||||
for _, feature := range record.features {
|
||||
if feature.record == nil {
|
||||
issues = append(issues, fmt.Errorf("command %q: invalid zero invocation feature", record.name))
|
||||
continue
|
||||
}
|
||||
for _, issue := range feature.record.issues {
|
||||
issues = append(issues, fmt.Errorf("command %q invocation feature: %w", record.name, issue))
|
||||
}
|
||||
}
|
||||
if record.rootOnly && !root {
|
||||
issues = append(issues, fmt.Errorf("root-only command %q is nested beneath another command", label))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user