@@ -54,12 +54,19 @@ func WithColor(c bool) OptionList {
5454 }
5555}
5656
57+ func WithValues (s bool ) OptionList {
58+ return func (r * Report ) {
59+ r .Show = s
60+ }
61+ }
62+
5763// listReport holds the state for reporting the list command results
5864type Report struct {
5965 Ctx context.Context
6066 Results []* Result
6167 Format string
6268 Color bool
69+ Show bool // show values for corresponding features
6370}
6471
6572// Report renders the list command results in the specified format
@@ -97,13 +104,21 @@ func (r *Report) detailedReport() {
97104 if result .Missing {
98105 presence = "missing"
99106 }
107+ show := r .Show
108+ fmt .Println ()
100109 fmt .Printf ("File: %s\t Feature: %s (%s)\n " , result .FilePath , result .Feature , presence )
101110
102111 // Initialize tablewriter
103112 table := tablewriter .NewWriter (os .Stdout )
104113 if strings .HasPrefix (result .Feature , "comp_" ) {
114+
115+ if show {
116+ table .SetHeader ([]string {"Feature" , "Component Name" , "Version" , "Value" })
117+ } else {
118+ table .SetHeader ([]string {"Feature" , "Component Name" , "Version" })
119+ }
120+
105121 // Component-based feature
106- table .SetHeader ([]string {"Feature" , "Component Name" , "Version" })
107122 featureCol := fmt .Sprintf ("%s (%d/%d)" , result .Feature , len (result .Components ), result .TotalComponents )
108123 if len (result .Components ) == 0 {
109124 // No components to display
@@ -119,29 +134,38 @@ func (r *Report) detailedReport() {
119134 versionCol := color .New (color .FgHiGreen ).Sprint (comp .Version )
120135 table .Append ([]string {featureCol1 , nameCol , versionCol })
121136 }
122- table .Append ([]string {featureCol , comp .Name , comp .Version })
123-
137+ if show {
138+ table .Append ([]string {featureCol , comp .Name , comp .Version , comp .Values })
139+ } else {
140+ table .Append ([]string {featureCol , comp .Name , comp .Version })
141+ }
124142 }
125143
126144 } else {
127145 // SBOM-based feature
128146 featureCol := fmt .Sprintf ("%s (%s)" , result .Feature , presence )
147+ table .SetHeader ([]string {"Feature" , "SBOM Feature" , "Value" })
148+
129149 if r .Color {
130150 featureCol1 := color .New (color .FgHiCyan ).Sprint (featureCol )
131151 propertyCol := color .New (color .FgHiBlue ).Sprint (result .DocumentProperty .Key )
132152 valueCol := color .New (color .FgHiBlue ).Sprint (result .DocumentProperty .Value )
133153 table .Append ([]string {featureCol1 , propertyCol , valueCol })
134154 } else {
135155 if result .DocumentProperty .Present {
156+ if result .DocumentProperty .Value == "" {
157+ result .DocumentProperty .Value = "N/A"
158+ }
136159 table .Append ([]string {featureCol , result .DocumentProperty .Key , result .DocumentProperty .Value })
137160 } else {
138- table .Append ([]string {featureCol , result .DocumentProperty .Key , "N/A" })
161+ if result .DocumentProperty .Value == "" {
162+ result .DocumentProperty .Value = "N/A"
163+ }
164+ table .Append ([]string {featureCol , result .DocumentProperty .Key , result .DocumentProperty .Value })
139165 }
140166 }
141167 }
142168
143- // Configure table settings
144- table .SetHeader ([]string {"Feature" , "Key/Component Name" , "Value/Version" })
145169 table .SetRowLine (true )
146170 table .SetColWidth (50 )
147171 table .SetAutoMergeCellsByColumnIndex ([]int {0 })
0 commit comments