@@ -45,6 +45,7 @@ pub struct TreeOptions {
4545 pub graph_features : bool ,
4646 /// Display depth of the dependency tree.
4747 /// If non-negative integer, display dependencies with that amount of max depth.
48+ /// If `workspace`, display dependencies from current workspace only.
4849 pub display_depth : DisplayDepth ,
4950 /// Excludes proc-macro dependencies.
5051 pub no_proc_macro : bool ,
@@ -90,18 +91,20 @@ impl FromStr for Prefix {
9091#[ derive( Clone , Copy ) ]
9192pub enum DisplayDepth {
9293 MaxDisplayDepth ( u32 ) ,
94+ Workspace ,
9395}
9496
9597impl FromStr for DisplayDepth {
9698 type Err = clap:: Error ;
9799
98100 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
99101 match s {
102+ "workspace" => Ok ( Self :: Workspace ) ,
100103 s => s. parse ( ) . map ( Self :: MaxDisplayDepth ) . map_err ( |_| {
101104 clap:: Error :: raw (
102105 clap:: error:: ErrorKind :: ValueValidation ,
103106 format ! (
104- "supported values for --depth are non-negative integers, \
107+ "supported values for --depth are non-negative integers and `workspace` , \
105108 but `{}` is unknown",
106109 s
107110 ) ,
@@ -403,8 +406,9 @@ fn print_dependencies<'a>(
403406 }
404407 }
405408
406- let max_display_depth = match display_depth {
407- DisplayDepth :: MaxDisplayDepth ( max) => max,
409+ let ( max_display_depth, filter_non_workspace_member) = match display_depth {
410+ DisplayDepth :: MaxDisplayDepth ( max) => ( max, false ) ,
411+ DisplayDepth :: Workspace => ( u32:: MAX , true ) ,
408412 } ;
409413
410414 // Current level exceeds maximum display depth. Skip.
@@ -418,6 +422,9 @@ fn print_dependencies<'a>(
418422 // Filter out packages to prune.
419423 match graph. node ( * * dep) {
420424 Node :: Package { package_id, .. } => {
425+ if filter_non_workspace_member && !ws. is_member_id ( * package_id) {
426+ return false ;
427+ }
421428 !pkgs_to_prune. iter ( ) . any ( |spec| spec. matches ( * package_id) )
422429 }
423430 _ => true ,
0 commit comments