@@ -62,6 +62,7 @@ type statusCommand struct {
62
62
detailed bool
63
63
json bool
64
64
template string
65
+ output string
65
66
dot bool
66
67
old bool
67
68
missing bool
@@ -152,6 +153,35 @@ func (out *jsonOutput) MissingFooter() {
152
153
json .NewEncoder (out .w ).Encode (out .missing )
153
154
}
154
155
156
+ type dotOutput struct {
157
+ w io.Writer
158
+ o string
159
+ g * graphviz
160
+ p * dep.Project
161
+ }
162
+
163
+ func (out * dotOutput ) BasicHeader () {
164
+ out .g = new (graphviz ).New ()
165
+
166
+ ptree , _ := pkgtree .ListPackages (out .p .AbsRoot , string (out .p .ImportRoot ))
167
+ prm , _ := ptree .ToReachMap (true , false , false , nil )
168
+
169
+ out .g .createNode (string (out .p .ImportRoot ), "" , prm .Flatten (false ))
170
+ }
171
+
172
+ func (out * dotOutput ) BasicFooter () {
173
+ gvo := out .g .output ()
174
+ fmt .Fprintf (out .w , gvo .String ())
175
+ }
176
+
177
+ func (out * dotOutput ) BasicLine (bs * BasicStatus ) {
178
+ out .g .createNode (bs .ProjectRoot , bs .Version .String (), bs .Children )
179
+ }
180
+
181
+ func (out * dotOutput ) MissingHeader () {}
182
+ func (out * dotOutput ) MissingLine (ms * MissingStatus ) {}
183
+ func (out * dotOutput ) MissingFooter () {}
184
+
155
185
func (cmd * statusCommand ) Run (ctx * dep.Ctx , args []string ) error {
156
186
p , err := ctx .LoadProject ("" )
157
187
if err != nil {
@@ -173,6 +203,12 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
173
203
out = & jsonOutput {
174
204
w : os .Stdout ,
175
205
}
206
+ case cmd .dot :
207
+ out = & dotOutput {
208
+ p : p ,
209
+ o : cmd .output ,
210
+ w : os .Stdout ,
211
+ }
176
212
default :
177
213
out = & tableOutput {
178
214
w : tabwriter .NewWriter (os .Stdout , 0 , 4 , 2 , ' ' , 0 ),
@@ -185,6 +221,7 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
185
221
// in the summary/list status output mode.
186
222
type BasicStatus struct {
187
223
ProjectRoot string
224
+ Children []string
188
225
Constraint gps.Constraint
189
226
Version gps.UnpairedVersion
190
227
Revision gps.Revision
@@ -248,6 +285,20 @@ func runStatusAll(out outputter, p *dep.Project, sm *gps.SourceMgr) error {
248
285
PackageCount : len (proj .Packages ()),
249
286
}
250
287
288
+ // Get children only for specific outputers
289
+ // in order to avoid slower status process
290
+ switch out .(type ) {
291
+ case * dotOutput :
292
+ ptr , err := sm .ListPackages (proj .Ident (), proj .Version ())
293
+
294
+ if err != nil {
295
+ return fmt .Errorf ("analysis of %s package failed: %v" , proj .Ident ().ProjectRoot , err )
296
+ }
297
+
298
+ prm , _ := ptr .ToReachMap (true , false , false , nil )
299
+ bs .Children = prm .Flatten (false )
300
+ }
301
+
251
302
// Split apart the version from the lock into its constituent parts
252
303
switch tv := proj .Version ().(type ) {
253
304
case gps.UnpairedVersion :
0 commit comments