Add detailed validation evidence
This commit is contained in:
@@ -20,6 +20,8 @@ type configCommandInput[I, S any] struct {
|
||||
sourceID commandkit.Supplied[string]
|
||||
details commandkit.Supplied[bool]
|
||||
check commandkit.Supplied[bool]
|
||||
severities []configkit.Severity
|
||||
codes []string
|
||||
values commandkit.FlagValues[I]
|
||||
againstValues commandkit.FlagValues[I]
|
||||
plan *configOperationPlan[I, S]
|
||||
@@ -45,6 +47,8 @@ type configOperationPlan[I, S any] struct {
|
||||
sourceID commandkit.Supplied[string]
|
||||
details bool
|
||||
check bool
|
||||
severities []configkit.Severity
|
||||
codes []string
|
||||
list bool
|
||||
help bool
|
||||
historical bool
|
||||
@@ -94,6 +98,17 @@ func newConfigOperationCommand[I, S any](prepared *preparedSuite[I, S], operatio
|
||||
}),
|
||||
)
|
||||
}
|
||||
if operation == Validate {
|
||||
flags = append(flags,
|
||||
commandkit.BoolFlag(commandkit.FlagMeta{Name: "details", Usage: "Show native validation findings."}, false, func(input **configCommandInput[I, S], value commandkit.Supplied[bool]) { (*input).details = value }),
|
||||
commandkit.RepeatFlag(commandkit.FlagMeta{Name: "severity", Usage: "Filter detailed findings by error or warning."}, []configkit.Severity(nil), parseValidationSeverity, func(input **configCommandInput[I, S], value commandkit.Supplied[[]configkit.Severity]) {
|
||||
(*input).severities = value.Value
|
||||
}),
|
||||
commandkit.RepeatFlag(commandkit.FlagMeta{Name: "code", Usage: "Filter detailed findings by exact native code."}, []string(nil), parseConfigString, func(input **configCommandInput[I, S], value commandkit.Supplied[[]string]) {
|
||||
(*input).codes = value.Value
|
||||
}),
|
||||
)
|
||||
}
|
||||
if supportsOverrides(prepared, operation) {
|
||||
flags = append(flags, commandkit.RepeatFlag(commandkit.FlagMeta{Name: "set", Usage: "Override POINTER=JSON (pointer keys cannot contain =)."}, []configkit.Override(nil), overrideParser("--set"),
|
||||
func(input **configCommandInput[I, S], value commandkit.Supplied[[]configkit.Override]) {
|
||||
@@ -179,6 +194,9 @@ func operationDeclaration(operation Operation) (string, string) {
|
||||
}
|
||||
|
||||
func prepareConfigOperation[I, S any](prepared *preparedSuite[I, S], operation Operation, input *configCommandInput[I, S]) error {
|
||||
if operation == Validate && !input.details.Value && (len(input.severities) > 0 || len(input.codes) > 0) {
|
||||
return fmt.Errorf("--severity and --code require --details")
|
||||
}
|
||||
if operation == Explain {
|
||||
if input.list.Value && input.path.Set {
|
||||
return fmt.Errorf("--list and --path cannot be combined")
|
||||
@@ -256,6 +274,8 @@ func prepareConfigOperation[I, S any](prepared *preparedSuite[I, S], operation O
|
||||
sourceID: input.sourceID,
|
||||
details: input.details.Value,
|
||||
check: input.check.Value,
|
||||
severities: append([]configkit.Severity(nil), input.severities...),
|
||||
codes: append([]string(nil), input.codes...),
|
||||
list: input.list.Value,
|
||||
historical: input.historical.Value,
|
||||
under: under,
|
||||
|
||||
Reference in New Issue
Block a user