From cafc0002e7429962e8f1ca48aa65d5f135d09def Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 30 Jul 2021 12:59:35 -0700 Subject: [PATCH 1/3] Remove `--all` from `cargo package`. --- src/bin/cargo/commands/package.rs | 2 +- src/cargo/util/command_prelude.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index daa0caaeaaa..081aa64e442 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -28,7 +28,7 @@ pub fn cli() -> App { .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_features() - .arg_package_spec( + .arg_package_spec_no_all( "Package(s) to assemble", "Assemble all packages in the workspace", "Don't assemble specified packages", diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 0f072f4a9ec..d17816133e8 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -27,6 +27,8 @@ pub type App = clap::App<'static, 'static>; pub trait AppExt: Sized { fn _arg(self, arg: Arg<'static, 'static>) -> Self; + /// Do not use this method, it is only for backwards compatibility. + /// Use `arg_package_spec_no_all` instead. fn arg_package_spec( self, package: &'static str, From 8306410c1b863a822bb82417ff9b79231fcfd378 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 30 Jul 2021 13:05:17 -0700 Subject: [PATCH 2/3] Remove duplicated code in arg_package_spec. --- src/cargo/util/command_prelude.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index d17816133e8..3253cfb1008 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -35,10 +35,8 @@ pub trait AppExt: Sized { all: &'static str, exclude: &'static str, ) -> Self { - self.arg_package_spec_simple(package) + self.arg_package_spec_no_all(package, all, exclude) ._arg(opt("all", "Alias for --workspace (deprecated)")) - ._arg(opt("workspace", all)) - ._arg(multi_opt("exclude", "SPEC", exclude)) } /// Variant of arg_package_spec that does not include the `--all` flag From 8e6f7ec5e660c9d95de76c5c2df42ebd4a774f20 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 30 Jul 2021 13:09:14 -0700 Subject: [PATCH 3/3] Update package/publish man pages for package selection. --- src/doc/man/cargo-package.md | 3 ++ src/doc/man/cargo-publish.md | 2 + src/doc/man/generated_txt/cargo-package.txt | 33 ++++++++++++++++ src/doc/man/generated_txt/cargo-publish.txt | 7 ++++ src/doc/src/commands/cargo-package.md | 42 +++++++++++++++++++++ src/doc/src/commands/cargo-publish.md | 16 ++++++++ src/etc/man/cargo-package.1 | 35 +++++++++++++++++ src/etc/man/cargo-publish.1 | 10 +++++ 8 files changed, 148 insertions(+) diff --git a/src/doc/man/cargo-package.md b/src/doc/man/cargo-package.md index a825299b0cf..4e84cf66432 100644 --- a/src/doc/man/cargo-package.md +++ b/src/doc/man/cargo-package.md @@ -1,5 +1,6 @@ # cargo-package(1) {{*set actionverb="Package"}} +{{*set noall=true}} ## NAME @@ -67,6 +68,8 @@ Allow working directories with uncommitted VCS changes to be packaged. {{/options}} +{{> section-package-selection }} + ### Compilation Options {{#options}} diff --git a/src/doc/man/cargo-publish.md b/src/doc/man/cargo-publish.md index 64b7bd6c79b..13ee736e935 100644 --- a/src/doc/man/cargo-publish.md +++ b/src/doc/man/cargo-publish.md @@ -63,6 +63,8 @@ which defaults to `crates-io`. {{/options}} +{{> section-options-package }} + ### Compilation Options {{#options}} diff --git a/src/doc/man/generated_txt/cargo-package.txt b/src/doc/man/generated_txt/cargo-package.txt index e0d52a4d352..018a306381b 100644 --- a/src/doc/man/generated_txt/cargo-package.txt +++ b/src/doc/man/generated_txt/cargo-package.txt @@ -61,6 +61,39 @@ OPTIONS Allow working directories with uncommitted VCS changes to be packaged. + Package Selection + By default, when no package selection options are given, the packages + selected depend on the selected manifest file (based on the current + working directory if --manifest-path is not given). If the manifest is + the root of a workspace then the workspaces default members are + selected, otherwise only the package defined by the manifest will be + selected. + + The default members of a workspace can be set explicitly with the + workspace.default-members key in the root manifest. If this is not set, + a virtual workspace will include all workspace members (equivalent to + passing --workspace), and a non-virtual workspace will include only the + root crate itself. + + -p spec..., --package spec... + Package only the specified packages. See cargo-pkgid(1) for the SPEC + format. This flag may be specified multiple times and supports + common Unix glob patterns like *, ? and []. However, to avoid your + shell accidentally expanding glob patterns before Cargo handles + them, you must use single quotes or double quotes around each + pattern. + + --workspace + Package all members in the workspace. + + --exclude SPEC... + Exclude the specified packages. Must be used in conjunction with the + --workspace flag. This flag may be specified multiple times and + supports common Unix glob patterns like *, ? and []. However, to + avoid your shell accidentally expanding glob patterns before Cargo + handles them, you must use single quotes or double quotes around + each pattern. + Compilation Options --target triple Package for the given architecture. The default is the host diff --git a/src/doc/man/generated_txt/cargo-publish.txt b/src/doc/man/generated_txt/cargo-publish.txt index dc214098bdc..f7eca5c4cf2 100644 --- a/src/doc/man/generated_txt/cargo-publish.txt +++ b/src/doc/man/generated_txt/cargo-publish.txt @@ -67,6 +67,13 @@ OPTIONS config key which defaults to crates-io. + Package Selection + By default, the package in the current working directory is selected. + The -p flag can be used to choose a different package in a workspace. + + -p spec, --package spec + The package to publish. See cargo-pkgid(1) for the SPEC format. + Compilation Options --target triple Publish for the given architecture. The default is the host diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md index e0935bd6154..b98e746bfc0 100644 --- a/src/doc/src/commands/cargo-package.md +++ b/src/doc/src/commands/cargo-package.md @@ -1,6 +1,7 @@ # cargo-package(1) + ## NAME cargo-package - Assemble the local package into a distributable tarball @@ -68,6 +69,47 @@ or the license). +### Package Selection + +By default, when no package selection options are given, the packages selected +depend on the selected manifest file (based on the current working directory if +`--manifest-path` is not given). If the manifest is the root of a workspace then +the workspaces default members are selected, otherwise only the package defined +by the manifest will be selected. + +The default members of a workspace can be set explicitly with the +`workspace.default-members` key in the root manifest. If this is not set, a +virtual workspace will include all workspace members (equivalent to passing +`--workspace`), and a non-virtual workspace will include only the root crate itself. + +
+ +
-p spec...
+
--package spec...
+
Package only the specified packages. See cargo-pkgid(1) for the +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like *, ? and []. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern.
+ + +
--workspace
+
Package all members in the workspace.
+ + + + +
--exclude SPEC...
+
Exclude the specified packages. Must be used in conjunction with the +--workspace flag. This flag may be specified multiple times and supports +common Unix glob patterns like *, ? and []. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern.
+ + +
+ + ### Compilation Options
diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md index 511688c1d37..6c86ea1fa0d 100644 --- a/src/doc/src/commands/cargo-publish.md +++ b/src/doc/src/commands/cargo-publish.md @@ -76,6 +76,22 @@ which defaults to crates-io.
+### Package Selection + +By default, the package in the current working directory is selected. The `-p` +flag can be used to choose a different package in a workspace. + +
+ +
-p spec
+
--package spec
+
The package to publish. See cargo-pkgid(1) for the SPEC +format.
+ + +
+ + ### Compilation Options
diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1 index 9fbce0bc0df..c7a7336a1d6 100644 --- a/src/etc/man/cargo-package.1 +++ b/src/etc/man/cargo-package.1 @@ -91,6 +91,41 @@ or the license). .RS 4 Allow working directories with uncommitted VCS changes to be packaged. .RE +.SS "Package Selection" +By default, when no package selection options are given, the packages selected +depend on the selected manifest file (based on the current working directory if +\fB\-\-manifest\-path\fR is not given). If the manifest is the root of a workspace then +the workspaces default members are selected, otherwise only the package defined +by the manifest will be selected. +.sp +The default members of a workspace can be set explicitly with the +\fBworkspace.default\-members\fR key in the root manifest. If this is not set, a +virtual workspace will include all workspace members (equivalent to passing +\fB\-\-workspace\fR), and a non\-virtual workspace will include only the root crate itself. +.sp +\fB\-p\fR \fIspec\fR\&..., +\fB\-\-package\fR \fIspec\fR\&... +.RS 4 +Package only the specified packages. See \fBcargo\-pkgid\fR(1) for the +SPEC format. This flag may be specified multiple times and supports common Unix +glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally +expanding glob patterns before Cargo handles them, you must use single quotes or +double quotes around each pattern. +.RE +.sp +\fB\-\-workspace\fR +.RS 4 +Package all members in the workspace. +.RE +.sp +\fB\-\-exclude\fR \fISPEC\fR\&... +.RS 4 +Exclude the specified packages. Must be used in conjunction with the +\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports +common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell +accidentally expanding glob patterns before Cargo handles them, you must use +single quotes or double quotes around each pattern. +.RE .SS "Compilation Options" .sp \fB\-\-target\fR \fItriple\fR diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1 index 04c2307ce3c..ab30257761f 100644 --- a/src/etc/man/cargo-publish.1 +++ b/src/etc/man/cargo-publish.1 @@ -82,6 +82,16 @@ Otherwise it will use the default registry, which is defined by the \fI\f(BIregistry.default\fI\fR config key which defaults to \fBcrates\-io\fR\&. .RE +.SS "Package Selection" +By default, the package in the current working directory is selected. The \fB\-p\fR +flag can be used to choose a different package in a workspace. +.sp +\fB\-p\fR \fIspec\fR, +\fB\-\-package\fR \fIspec\fR +.RS 4 +The package to publish. See \fBcargo\-pkgid\fR(1) for the SPEC +format. +.RE .SS "Compilation Options" .sp \fB\-\-target\fR \fItriple\fR