From f2509b8052a0e8761854886cd219370e932a2086 Mon Sep 17 00:00:00 2001 From: Matt Rutkowski Date: Mon, 6 May 2024 11:12:49 -0500 Subject: [PATCH] Consolidate report/list formatting flags Signed-off-by: Matt Rutkowski --- utils/flags.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/utils/flags.go b/utils/flags.go index cb0362f9..6d5c041e 100644 --- a/utils/flags.go +++ b/utils/flags.go @@ -70,17 +70,21 @@ func (persistentFlags PersistentCommandFlags) GetOutputIndentInt() int { return int(persistentFlags.OutputIndent) } -type LicenseCommandFlags struct { +// Common flags for all "list" (report) commands (e.g., license list, vulnerability list, etc.) +type ReportCommandFlags struct { Summary bool - ListLineWrap bool + ListLineWrap bool // NOTE: SHOULD ONLY be used for "text" output; currently only used by "license policy" command. +} + +type LicenseCommandFlags struct { + ReportCommandFlags } type ValidateCommandFlags struct { SchemaVariant string ForcedJsonSchemaFile string - // Uses custom validation flags if "true"; defaults to config. "custom.json" - CustomValidation bool - // error result processing + CustomValidation bool // Uses custom validation flags if "true"; defaults to config. "custom.json" + // validation error result (output) processing MaxNumErrors int MaxErrorDescriptionLength int ColorizeErrorOutput bool @@ -88,7 +92,7 @@ type ValidateCommandFlags struct { } type VulnerabilityCommandFlags struct { - Summary bool + ReportCommandFlags } type DiffCommandFlags struct { @@ -97,12 +101,13 @@ type DiffCommandFlags struct { } type ResourceCommandFlags struct { - ResourceType string + ReportCommandFlags // NOTE: currently unused; as # columns grows, please implement + ResourceType string } type ComponentCommandFlags struct { - Summary bool - Types []string + ReportCommandFlags + Types []string } func NewResourceCommandFlags(resourceType string) ResourceCommandFlags { @@ -112,8 +117,10 @@ func NewResourceCommandFlags(resourceType string) ResourceCommandFlags { } type SchemaCommandFlags struct { + ReportCommandFlags // NOTE: currently unused; as # columns grows, please implement } +// TODO: unused/unimplemented type StatsCommandFlags struct { }