@@ -43,6 +43,8 @@ pub struct TreeOptions {
43
43
pub format : String ,
44
44
/// Includes features in the tree as separate nodes.
45
45
pub graph_features : bool ,
46
+ /// Maximum display depth of the dependency tree.
47
+ pub max_display_depth : u32 ,
46
48
}
47
49
48
50
#[ derive( PartialEq ) ]
@@ -241,6 +243,7 @@ fn print(
241
243
symbols,
242
244
opts. prefix ,
243
245
opts. no_dedupe ,
246
+ opts. max_display_depth ,
244
247
& mut visited_deps,
245
248
& mut levels_continue,
246
249
& mut print_stack,
@@ -259,6 +262,7 @@ fn print_node<'a>(
259
262
symbols : & Symbols ,
260
263
prefix : Prefix ,
261
264
no_dedupe : bool ,
265
+ max_display_depth : u32 ,
262
266
visited_deps : & mut HashSet < usize > ,
263
267
levels_continue : & mut Vec < bool > ,
264
268
print_stack : & mut Vec < usize > ,
@@ -316,6 +320,7 @@ fn print_node<'a>(
316
320
symbols,
317
321
prefix,
318
322
no_dedupe,
323
+ max_display_depth,
319
324
visited_deps,
320
325
levels_continue,
321
326
print_stack,
@@ -334,6 +339,7 @@ fn print_dependencies<'a>(
334
339
symbols : & Symbols ,
335
340
prefix : Prefix ,
336
341
no_dedupe : bool ,
342
+ max_display_depth : u32 ,
337
343
visited_deps : & mut HashSet < usize > ,
338
344
levels_continue : & mut Vec < bool > ,
339
345
print_stack : & mut Vec < usize > ,
@@ -364,19 +370,22 @@ fn print_dependencies<'a>(
364
370
365
371
let mut it = deps. iter ( ) . peekable ( ) ;
366
372
while let Some ( dependency) = it. next ( ) {
367
- levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
368
- print_node (
369
- config,
370
- graph,
371
- * dependency,
372
- format,
373
- symbols,
374
- prefix,
375
- no_dedupe,
376
- visited_deps,
377
- levels_continue,
378
- print_stack,
379
- ) ;
380
- levels_continue. pop ( ) ;
373
+ if levels_continue. len ( ) + 1 <= max_display_depth as usize {
374
+ levels_continue. push ( it. peek ( ) . is_some ( ) ) ;
375
+ print_node (
376
+ config,
377
+ graph,
378
+ * dependency,
379
+ format,
380
+ symbols,
381
+ prefix,
382
+ no_dedupe,
383
+ max_display_depth,
384
+ visited_deps,
385
+ levels_continue,
386
+ print_stack,
387
+ ) ;
388
+ levels_continue. pop ( ) ;
389
+ }
381
390
}
382
391
}
0 commit comments