1+ use crate :: cli;
12use crate :: command_prelude:: * ;
23use anyhow:: { bail, format_err} ;
34use cargo:: core:: dependency:: DepKind ;
@@ -88,9 +89,22 @@ pub fn cli() -> App {
8889 . short ( "f" )
8990 . default_value ( "{p}" ) ,
9091 )
92+ . arg (
93+ // Backwards compatibility with old cargo-tree.
94+ Arg :: with_name ( "version" )
95+ . long ( "version" )
96+ . short ( "V" )
97+ . hidden ( true ) ,
98+ )
9199}
92100
93101pub fn exec ( config : & mut Config , args : & ArgMatches < ' _ > ) -> CliResult {
102+ if args. is_present ( "version" ) {
103+ let verbose = args. occurrences_of ( "verbose" ) > 0 ;
104+ let version = cli:: get_version_string ( verbose) ;
105+ print ! ( "{}" , version) ;
106+ return Ok ( ( ) ) ;
107+ }
94108 let prefix = if args. is_present ( "no-indent" ) {
95109 config
96110 . shell ( )
@@ -106,12 +120,13 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
106120 } ;
107121 let prefix = tree:: Prefix :: from_str ( prefix) . map_err ( |e| anyhow:: anyhow!( "{}" , e) ) ?;
108122
123+ let no_dedupe = args. is_present ( "no-dedupe" ) || args. is_present ( "all" ) ;
109124 if args. is_present ( "all" ) {
110- return Err ( format_err ! (
111- "The `cargo tree` --all flag has been changed to --no-dedupe. \n \
112- If you are looking to display all workspace members, use the --workspace flag."
113- )
114- . into ( ) ) ;
125+ config . shell ( ) . warn (
126+ "The `cargo tree` --all flag has been changed to --no-dedupe, \
127+ and may be removed in a future version. \n \
128+ If you are looking to display all workspace members, use the --workspace flag." ,
129+ ) ? ;
115130 }
116131
117132 let target = if args. is_present ( "all-targets" ) {
@@ -170,7 +185,7 @@ subtree of the package given to -p.\n\
170185 edge_kinds,
171186 invert,
172187 prefix,
173- no_dedupe : args . is_present ( "no-dedupe" ) ,
188+ no_dedupe,
174189 duplicates : args. is_present ( "duplicates" ) ,
175190 charset,
176191 format : args. value_of ( "format" ) . unwrap ( ) . to_string ( ) ,
0 commit comments