@@ -31,6 +31,7 @@ var rootFlags struct {
31
31
Name * string
32
32
Advanced * string
33
33
JSON * bool
34
+ Details * bool
34
35
}
35
36
36
37
func root (c * cobra.Command , args []string ) {
@@ -73,10 +74,7 @@ func root(c *cobra.Command, args []string) {
73
74
o , _ := os .Stdout .Stat ()
74
75
isTerminal := (o .Mode () & os .ModeCharDevice ) == os .ModeCharDevice
75
76
76
- showVersion := true
77
- showDescription := true
78
- showLicenses := true
79
- showHomepage := true
77
+ showDetails := * rootFlags .Details
80
78
81
79
for _ , pkg := range packages {
82
80
// If asked to spit out json, just dump the packages directly
@@ -92,45 +90,44 @@ func root(c *cobra.Command, args []string) {
92
90
fmt .Print (": " , programs )
93
91
}
94
92
fmt .Println ()
95
- if showVersion {
96
- fmt . Printf ( " version: %s \n " , pkg . Version )
93
+ if ! showDetails {
94
+ continue
97
95
}
98
- if showDescription {
99
- d := ""
100
- if pkg . Description != nil {
101
- d = * pkg . Description
102
- }
103
- fmt . Printf ( " description: %s \n " , d )
96
+ // version
97
+ fmt . Printf ( " version: %s \n " , pkg . Version )
98
+ // description
99
+ d := ""
100
+ if pkg . Description != nil {
101
+ d = * pkg . Description
104
102
}
105
- if showLicenses {
106
- fmt .Printf (" license:" )
107
- if len (pkg .Licenses ) == 1 {
108
- license := pkg .Licenses [0 ]
103
+ fmt .Printf (" description: %s\n " , d )
104
+ // license
105
+ fmt .Printf (" license:" )
106
+ if len (pkg .Licenses ) == 1 {
107
+ license := pkg .Licenses [0 ]
108
+ txt := license .FullName
109
+ if isTerminal && license .URL != nil {
110
+ txt = escapes .Link (* license .URL , license .FullName )
111
+ }
112
+ fmt .Printf (" %s\n " , txt )
113
+ } else {
114
+ fmt .Printf ("\n " )
115
+ for _ , license := range pkg .Licenses {
109
116
txt := license .FullName
110
117
if isTerminal && license .URL != nil {
111
118
txt = escapes .Link (* license .URL , license .FullName )
112
119
}
113
- fmt .Printf (" %s\n " , txt )
114
- } else {
115
- fmt .Printf ("\n " )
116
- for _ , license := range pkg .Licenses {
117
- txt := license .FullName
118
- if isTerminal && license .URL != nil {
119
- txt = escapes .Link (* license .URL , license .FullName )
120
- }
121
- fmt .Printf (" - %s\n " , txt )
122
- }
120
+ fmt .Printf (" - %s\n " , txt )
123
121
}
124
122
}
125
- if showHomepage {
126
- fmt .Printf (" homepage:" )
127
- if len (pkg .Homepage ) == 1 {
128
- fmt .Printf (" %s\n " , pkg .Homepage [0 ])
129
- } else {
130
- fmt .Printf ("\n " )
131
- for _ , homepage := range pkg .Homepage {
132
- fmt .Printf (" - %s\n " , homepage )
133
- }
123
+ // homepage
124
+ fmt .Printf (" homepage:" )
125
+ if len (pkg .Homepage ) == 1 {
126
+ fmt .Printf (" %s\n " , pkg .Homepage [0 ])
127
+ } else {
128
+ fmt .Printf ("\n " )
129
+ for _ , homepage := range pkg .Homepage {
130
+ fmt .Printf (" - %s\n " , homepage )
134
131
}
135
132
}
136
133
}
@@ -181,6 +178,7 @@ func main() {
181
178
rootFlags .Name = rootCommand .Flags ().StringP ("name" , "n" , "" , "search by attr name" )
182
179
rootFlags .Advanced = rootCommand .Flags ().StringP ("advanced" , "a" , "" , "perform an advanced query string format search" )
183
180
rootFlags .JSON = rootCommand .Flags ().BoolP ("json" , "j" , false , "emit results in json-line format" )
181
+ rootFlags .Details = rootCommand .Flags ().BoolP ("details" , "d" , false , "show expanded details for each result" )
184
182
185
183
if err := rootCommand .Execute (); err != nil {
186
184
panic (err )
0 commit comments