Add shared report format flag
This commit is contained in:
12
parser.go
12
parser.go
@@ -24,6 +24,18 @@ func reduceReportingOccurrences(result commandmeta.Result) commandmeta.Result {
|
||||
if !commandmeta.IsReportingFlag(occurrence.Name) {
|
||||
continue
|
||||
}
|
||||
if occurrence.Name == "format" {
|
||||
switch Format(occurrence.RawValue) {
|
||||
case FormatText, FormatYAML, FormatJSON:
|
||||
selection.Format = occurrence.RawValue
|
||||
default:
|
||||
result.FlagOccurrences = result.FlagOccurrences[:index+1]
|
||||
result.Reporting = selection
|
||||
result.Failure = &commandmeta.Failure{Message: fmt.Sprintf("invalid format %q for %s (expected text, yaml, or json)", occurrence.RawValue, occurrence.Spelling), Usage: true}
|
||||
return result
|
||||
}
|
||||
continue
|
||||
}
|
||||
enabled, err := strconv.ParseBool(occurrence.RawValue)
|
||||
if err != nil {
|
||||
result.FlagOccurrences = result.FlagOccurrences[:index+1]
|
||||
|
||||
Reference in New Issue
Block a user