diff --git a/src/bin/cargo/commands/publish.rs b/src/bin/cargo/commands/publish.rs index df1c4654ffe..42b6377c7e4 100644 --- a/src/bin/cargo/commands/publish.rs +++ b/src/bin/cargo/commands/publish.rs @@ -18,7 +18,11 @@ pub fn cli() -> Command { "Allow dirty working directories to be packaged", )) .arg_silent_suggestion() - .arg_package("Package to publish") + .arg_package_spec_no_all( + "Package(s) to publish", + "Publish all packages in the workspace (unstable)", + "Don't publish specified packages (unstable)", + ) .arg_features() .arg_parallel() .arg_target_triple("Build for the target triple") @@ -41,6 +45,23 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { .into()); } + let unstable = gctx.cli_unstable(); + let enabled = unstable.package_workspace; + if args.get_flag("workspace") { + unstable.fail_if_stable_opt_custom_z("--workspace", 10948, "package-workspace", enabled)?; + } + if args._value_of("exclude").is_some() { + unstable.fail_if_stable_opt_custom_z("--exclude", 10948, "package-workspace", enabled)?; + } + if args._values_of("package").len() > 1 { + unstable.fail_if_stable_opt_custom_z( + "--package (multiple occurrences)", + 10948, + "package-workspace", + enabled, + )?; + } + ops::publish( &ws, &PublishOpts { diff --git a/tests/testsuite/cargo_publish/help/stdout.term.svg b/tests/testsuite/cargo_publish/help/stdout.term.svg index c678fe8f83c..40981eb68db 100644 --- a/tests/testsuite/cargo_publish/help/stdout.term.svg +++ b/tests/testsuite/cargo_publish/help/stdout.term.svg @@ -1,4 +1,4 @@ - +