Skip to content

Commit cd253b0

Browse files
committedJul 30, 2021
Auto merge of #9749 - ehuss:no_all-package, r=alexcrichton
Some minor updates for package/publish package selection. This is just a few small things I missed in the review of #9559. * Don't include the deprecated `--all` flag in `cargo package`. * Update the man pages for the new flags.
2 parents 8b0671a + 8e6f7ec commit cd253b0

File tree

10 files changed

+152
-4
lines changed

10 files changed

+152
-4
lines changed
 

‎src/bin/cargo/commands/package.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn cli() -> App {
2828
.arg_target_triple("Build for the target triple")
2929
.arg_target_dir()
3030
.arg_features()
31-
.arg_package_spec(
31+
.arg_package_spec_no_all(
3232
"Package(s) to assemble",
3333
"Assemble all packages in the workspace",
3434
"Don't assemble specified packages",

‎src/cargo/util/command_prelude.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ pub type App = clap::App<'static, 'static>;
2727
pub trait AppExt: Sized {
2828
fn _arg(self, arg: Arg<'static, 'static>) -> Self;
2929

30+
/// Do not use this method, it is only for backwards compatibility.
31+
/// Use `arg_package_spec_no_all` instead.
3032
fn arg_package_spec(
3133
self,
3234
package: &'static str,
3335
all: &'static str,
3436
exclude: &'static str,
3537
) -> Self {
36-
self.arg_package_spec_simple(package)
38+
self.arg_package_spec_no_all(package, all, exclude)
3739
._arg(opt("all", "Alias for --workspace (deprecated)"))
38-
._arg(opt("workspace", all))
39-
._arg(multi_opt("exclude", "SPEC", exclude))
4040
}
4141

4242
/// Variant of arg_package_spec that does not include the `--all` flag

‎src/doc/man/cargo-package.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# cargo-package(1)
22
{{*set actionverb="Package"}}
3+
{{*set noall=true}}
34

45
## NAME
56

@@ -67,6 +68,8 @@ Allow working directories with uncommitted VCS changes to be packaged.
6768

6869
{{/options}}
6970

71+
{{> section-package-selection }}
72+
7073
### Compilation Options
7174

7275
{{#options}}

‎src/doc/man/cargo-publish.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ which defaults to `crates-io`.
6363

6464
{{/options}}
6565

66+
{{> section-options-package }}
67+
6668
### Compilation Options
6769

6870
{{#options}}

‎src/doc/man/generated_txt/cargo-package.txt

+33
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,39 @@ OPTIONS
6161
Allow working directories with uncommitted VCS changes to be
6262
packaged.
6363

64+
Package Selection
65+
By default, when no package selection options are given, the packages
66+
selected depend on the selected manifest file (based on the current
67+
working directory if --manifest-path is not given). If the manifest is
68+
the root of a workspace then the workspaces default members are
69+
selected, otherwise only the package defined by the manifest will be
70+
selected.
71+
72+
The default members of a workspace can be set explicitly with the
73+
workspace.default-members key in the root manifest. If this is not set,
74+
a virtual workspace will include all workspace members (equivalent to
75+
passing --workspace), and a non-virtual workspace will include only the
76+
root crate itself.
77+
78+
-p spec..., --package spec...
79+
Package only the specified packages. See cargo-pkgid(1) for the SPEC
80+
format. This flag may be specified multiple times and supports
81+
common Unix glob patterns like *, ? and []. However, to avoid your
82+
shell accidentally expanding glob patterns before Cargo handles
83+
them, you must use single quotes or double quotes around each
84+
pattern.
85+
86+
--workspace
87+
Package all members in the workspace.
88+
89+
--exclude SPEC...
90+
Exclude the specified packages. Must be used in conjunction with the
91+
--workspace flag. This flag may be specified multiple times and
92+
supports common Unix glob patterns like *, ? and []. However, to
93+
avoid your shell accidentally expanding glob patterns before Cargo
94+
handles them, you must use single quotes or double quotes around
95+
each pattern.
96+
6497
Compilation Options
6598
--target triple
6699
Package for the given architecture. The default is the host

‎src/doc/man/generated_txt/cargo-publish.txt

+7
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ OPTIONS
6767
<https://doc.rust-lang.org/cargo/reference/config.html#registrydefault>
6868
config key which defaults to crates-io.
6969

70+
Package Selection
71+
By default, the package in the current working directory is selected.
72+
The -p flag can be used to choose a different package in a workspace.
73+
74+
-p spec, --package spec
75+
The package to publish. See cargo-pkgid(1) for the SPEC format.
76+
7077
Compilation Options
7178
--target triple
7279
Publish for the given architecture. The default is the host

‎src/doc/src/commands/cargo-package.md

+42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# cargo-package(1)
22

33

4+
45
## NAME
56

67
cargo-package - Assemble the local package into a distributable tarball
@@ -68,6 +69,47 @@ or the license).</dd>
6869

6970
</dl>
7071

72+
### Package Selection
73+
74+
By default, when no package selection options are given, the packages selected
75+
depend on the selected manifest file (based on the current working directory if
76+
`--manifest-path` is not given). If the manifest is the root of a workspace then
77+
the workspaces default members are selected, otherwise only the package defined
78+
by the manifest will be selected.
79+
80+
The default members of a workspace can be set explicitly with the
81+
`workspace.default-members` key in the root manifest. If this is not set, a
82+
virtual workspace will include all workspace members (equivalent to passing
83+
`--workspace`), and a non-virtual workspace will include only the root crate itself.
84+
85+
<dl>
86+
87+
<dt class="option-term" id="option-cargo-package--p"><a class="option-anchor" href="#option-cargo-package--p"></a><code>-p</code> <em>spec</em>...</dt>
88+
<dt class="option-term" id="option-cargo-package---package"><a class="option-anchor" href="#option-cargo-package---package"></a><code>--package</code> <em>spec</em>...</dt>
89+
<dd class="option-desc">Package only the specified packages. See <a href="cargo-pkgid.html">cargo-pkgid(1)</a> for the
90+
SPEC format. This flag may be specified multiple times and supports common Unix
91+
glob patterns like <code>*</code>, <code>?</code> and <code>[]</code>. However, to avoid your shell accidentally
92+
expanding glob patterns before Cargo handles them, you must use single quotes or
93+
double quotes around each pattern.</dd>
94+
95+
96+
<dt class="option-term" id="option-cargo-package---workspace"><a class="option-anchor" href="#option-cargo-package---workspace"></a><code>--workspace</code></dt>
97+
<dd class="option-desc">Package all members in the workspace.</dd>
98+
99+
100+
101+
102+
<dt class="option-term" id="option-cargo-package---exclude"><a class="option-anchor" href="#option-cargo-package---exclude"></a><code>--exclude</code> <em>SPEC</em>...</dt>
103+
<dd class="option-desc">Exclude the specified packages. Must be used in conjunction with the
104+
<code>--workspace</code> flag. This flag may be specified multiple times and supports
105+
common Unix glob patterns like <code>*</code>, <code>?</code> and <code>[]</code>. However, to avoid your shell
106+
accidentally expanding glob patterns before Cargo handles them, you must use
107+
single quotes or double quotes around each pattern.</dd>
108+
109+
110+
</dl>
111+
112+
71113
### Compilation Options
72114

73115
<dl>

‎src/doc/src/commands/cargo-publish.md

+16
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ which defaults to <code>crates-io</code>.</dd>
7676

7777
</dl>
7878

79+
### Package Selection
80+
81+
By default, the package in the current working directory is selected. The `-p`
82+
flag can be used to choose a different package in a workspace.
83+
84+
<dl>
85+
86+
<dt class="option-term" id="option-cargo-publish--p"><a class="option-anchor" href="#option-cargo-publish--p"></a><code>-p</code> <em>spec</em></dt>
87+
<dt class="option-term" id="option-cargo-publish---package"><a class="option-anchor" href="#option-cargo-publish---package"></a><code>--package</code> <em>spec</em></dt>
88+
<dd class="option-desc">The package to publish. See <a href="cargo-pkgid.html">cargo-pkgid(1)</a> for the SPEC
89+
format.</dd>
90+
91+
92+
</dl>
93+
94+
7995
### Compilation Options
8096

8197
<dl>

‎src/etc/man/cargo-package.1

+35
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,41 @@ or the license).
9191
.RS 4
9292
Allow working directories with uncommitted VCS changes to be packaged.
9393
.RE
94+
.SS "Package Selection"
95+
By default, when no package selection options are given, the packages selected
96+
depend on the selected manifest file (based on the current working directory if
97+
\fB\-\-manifest\-path\fR is not given). If the manifest is the root of a workspace then
98+
the workspaces default members are selected, otherwise only the package defined
99+
by the manifest will be selected.
100+
.sp
101+
The default members of a workspace can be set explicitly with the
102+
\fBworkspace.default\-members\fR key in the root manifest. If this is not set, a
103+
virtual workspace will include all workspace members (equivalent to passing
104+
\fB\-\-workspace\fR), and a non\-virtual workspace will include only the root crate itself.
105+
.sp
106+
\fB\-p\fR \fIspec\fR\&...,
107+
\fB\-\-package\fR \fIspec\fR\&...
108+
.RS 4
109+
Package only the specified packages. See \fBcargo\-pkgid\fR(1) for the
110+
SPEC format. This flag may be specified multiple times and supports common Unix
111+
glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally
112+
expanding glob patterns before Cargo handles them, you must use single quotes or
113+
double quotes around each pattern.
114+
.RE
115+
.sp
116+
\fB\-\-workspace\fR
117+
.RS 4
118+
Package all members in the workspace.
119+
.RE
120+
.sp
121+
\fB\-\-exclude\fR \fISPEC\fR\&...
122+
.RS 4
123+
Exclude the specified packages. Must be used in conjunction with the
124+
\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports
125+
common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell
126+
accidentally expanding glob patterns before Cargo handles them, you must use
127+
single quotes or double quotes around each pattern.
128+
.RE
94129
.SS "Compilation Options"
95130
.sp
96131
\fB\-\-target\fR \fItriple\fR

‎src/etc/man/cargo-publish.1

+10
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ Otherwise it will use the default registry, which is defined by the
8282
\fI\f(BIregistry.default\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#registrydefault> config key
8383
which defaults to \fBcrates\-io\fR\&.
8484
.RE
85+
.SS "Package Selection"
86+
By default, the package in the current working directory is selected. The \fB\-p\fR
87+
flag can be used to choose a different package in a workspace.
88+
.sp
89+
\fB\-p\fR \fIspec\fR,
90+
\fB\-\-package\fR \fIspec\fR
91+
.RS 4
92+
The package to publish. See \fBcargo\-pkgid\fR(1) for the SPEC
93+
format.
94+
.RE
8595
.SS "Compilation Options"
8696
.sp
8797
\fB\-\-target\fR \fItriple\fR

0 commit comments

Comments
 (0)
Please sign in to comment.