@@ -32,15 +32,27 @@ pub fn cli() -> Command {
32
32
"versioned-dirs" ,
33
33
"Always include version in subdir name" ,
34
34
) )
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" ) )
39
39
. arg_quiet ( )
40
40
. arg_manifest_path ( )
41
41
. after_help ( "Run `cargo help vendor` for more detailed information.\n " )
42
42
}
43
43
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
+
44
56
pub fn exec ( config : & mut Config , args : & ArgMatches ) -> CliResult {
45
57
// We're doing the vendoring operation ourselves, so we don't actually want
46
58
// 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 {
50
62
config. values_mut ( ) ?. remove ( "source" ) ;
51
63
}
52
64
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
-
81
65
let ws = args. workspace ( config) ?;
82
66
let path = args
83
67
. get_one :: < PathBuf > ( "path" )
0 commit comments