@@ -32,15 +32,27 @@ pub fn cli() -> Command {
3232 "versioned-dirs" ,
3333 "Always include version in subdir name" ,
3434 ) )
35- . arg ( flag ( "no-merge-sources" , "Not supported" ) . hide ( true ) )
36- . arg ( flag ( "relative-path" , "Not supported" ) . hide ( true ) )
37- . arg ( flag ( "only-git-deps" , "Not supported" ) . hide ( true ) )
38- . arg ( flag ( "disallow-duplicates" , "Not supported" ) . hide ( true ) )
35+ . arg ( unsupported ( "no-merge-sources" ) )
36+ . arg ( unsupported ( "relative-path" ) )
37+ . arg ( unsupported ( "only-git-deps" ) )
38+ . arg ( unsupported ( "disallow-duplicates" ) )
3939 . arg_quiet ( )
4040 . arg_manifest_path ( )
4141 . after_help ( "Run `cargo help vendor` for more detailed information.\n " )
4242}
4343
44+ fn unsupported ( name : & ' static str ) -> Arg {
45+ // When we moved `cargo vendor` into Cargo itself we didn't stabilize a few
46+ // flags, so try to provide a helpful error message in that case to ensure
47+ // that users currently using the flag aren't tripped up.
48+ let value_parser = clap:: builder:: UnknownArgumentValueParser :: suggest ( "the crates.io `cargo vendor` command has been merged into Cargo" )
49+ . and_suggest ( format ! ( "and the flag `--{name}` isn't supported currently" ) )
50+ . and_suggest ( "to continue using the flag, execute `cargo-vendor vendor ...`" )
51+ . and_suggest ( "to suggest this flag supported in Cargo, file an issue at <https://github.com/rust-lang/cargo/issues/new>" ) ;
52+
53+ flag ( name, "" ) . value_parser ( value_parser) . hide ( true )
54+ }
55+
4456pub fn exec ( config : & mut Config , args : & ArgMatches ) -> CliResult {
4557 // We're doing the vendoring operation ourselves, so we don't actually want
4658 // to respect any of the `source` configuration in Cargo itself. That's
@@ -50,34 +62,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
5062 config. values_mut ( ) ?. remove ( "source" ) ;
5163 }
5264
53- // When we moved `cargo vendor` into Cargo itself we didn't stabilize a few
54- // flags, so try to provide a helpful error message in that case to ensure
55- // that users currently using the flag aren't tripped up.
56- let crates_io_cargo_vendor_flag = if args. flag ( "no-merge-sources" ) {
57- Some ( "--no-merge-sources" )
58- } else if args. flag ( "relative-path" ) {
59- Some ( "--relative-path" )
60- } else if args. flag ( "only-git-deps" ) {
61- Some ( "--only-git-deps" )
62- } else if args. flag ( "disallow-duplicates" ) {
63- Some ( "--disallow-duplicates" )
64- } else {
65- None
66- } ;
67- if let Some ( flag) = crates_io_cargo_vendor_flag {
68- return Err ( anyhow:: format_err!(
69- "\
70- the crates.io `cargo vendor` command has now been merged into Cargo itself
71- and does not support the flag `{}` currently; to continue using the flag you
72- can execute `cargo-vendor vendor ...`, and if you would like to see this flag
73- supported in Cargo itself please feel free to file an issue at
74- https://github.com/rust-lang/cargo/issues/new
75- " ,
76- flag
77- )
78- . into ( ) ) ;
79- }
80-
8165 let ws = args. workspace ( config) ?;
8266 let path = args
8367 . get_one :: < PathBuf > ( "path" )
0 commit comments