1
+ use crate :: cli;
1
2
use crate :: command_prelude:: * ;
2
3
use anyhow:: { bail, format_err} ;
3
4
use cargo:: core:: dependency:: DepKind ;
@@ -88,9 +89,22 @@ pub fn cli() -> App {
88
89
. short ( "f" )
89
90
. default_value ( "{p}" ) ,
90
91
)
92
+ . arg (
93
+ // Backwards compatibility with old cargo-tree.
94
+ Arg :: with_name ( "version" )
95
+ . long ( "version" )
96
+ . short ( "V" )
97
+ . hidden ( true ) ,
98
+ )
91
99
}
92
100
93
101
pub 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
+ }
94
108
let prefix = if args. is_present ( "no-indent" ) {
95
109
config
96
110
. shell ( )
@@ -106,12 +120,13 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
106
120
} ;
107
121
let prefix = tree:: Prefix :: from_str ( prefix) . map_err ( |e| anyhow:: anyhow!( "{}" , e) ) ?;
108
122
123
+ let no_dedupe = args. is_present ( "no-dedupe" ) || args. is_present ( "all" ) ;
109
124
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
+ ) ? ;
115
130
}
116
131
117
132
let target = if args. is_present ( "all-targets" ) {
@@ -170,7 +185,7 @@ subtree of the package given to -p.\n\
170
185
edge_kinds,
171
186
invert,
172
187
prefix,
173
- no_dedupe : args . is_present ( "no-dedupe" ) ,
188
+ no_dedupe,
174
189
duplicates : args. is_present ( "duplicates" ) ,
175
190
charset,
176
191
format : args. value_of ( "format" ) . unwrap ( ) . to_string ( ) ,
0 commit comments