mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Support package selection in cargo publish
This commit is contained in:
parent
3ffcdee1ce
commit
4e051c47be
@ -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 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
<svg width="827px" height="776px" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg width="827px" height="812px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
@ -59,49 +59,53 @@
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan class="fg-green bold">Package Selection:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan> </tspan><tspan class="fg-cyan bold">-p</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--package</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan"><SPEC></tspan><tspan class="fg-cyan">]</tspan><tspan> Package to publish</tspan>
|
||||
<tspan x="10px" y="388px"><tspan> </tspan><tspan class="fg-cyan bold">-p</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--package</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan"><SPEC></tspan><tspan class="fg-cyan">]</tspan><tspan> Package(s) to publish</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px">
|
||||
<tspan x="10px" y="406px"><tspan> </tspan><tspan class="fg-cyan bold">--workspace</tspan><tspan> Publish all packages in the workspace (unstable)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px"><tspan class="fg-green bold">Feature Selection:</tspan>
|
||||
<tspan x="10px" y="424px"><tspan> </tspan><tspan class="fg-cyan bold">--exclude</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><SPEC></tspan><tspan> Don't publish specified packages (unstable)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="442px"><tspan> </tspan><tspan class="fg-cyan bold">-F</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--features</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><FEATURES></tspan><tspan> Space or comma separated list of features to activate</tspan>
|
||||
<tspan x="10px" y="442px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="460px"><tspan> </tspan><tspan class="fg-cyan bold">--all-features</tspan><tspan> Activate all available features</tspan>
|
||||
<tspan x="10px" y="460px"><tspan class="fg-green bold">Feature Selection:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="478px"><tspan> </tspan><tspan class="fg-cyan bold">--no-default-features</tspan><tspan> Do not activate the `default` feature</tspan>
|
||||
<tspan x="10px" y="478px"><tspan> </tspan><tspan class="fg-cyan bold">-F</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--features</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><FEATURES></tspan><tspan> Space or comma separated list of features to activate</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="496px">
|
||||
<tspan x="10px" y="496px"><tspan> </tspan><tspan class="fg-cyan bold">--all-features</tspan><tspan> Activate all available features</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="514px"><tspan class="fg-green bold">Compilation Options:</tspan>
|
||||
<tspan x="10px" y="514px"><tspan> </tspan><tspan class="fg-cyan bold">--no-default-features</tspan><tspan> Do not activate the `default` feature</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="532px"><tspan> </tspan><tspan class="fg-cyan bold">-j</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--jobs</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><N></tspan><tspan> Number of parallel jobs, defaults to # of CPUs.</tspan>
|
||||
<tspan x="10px" y="532px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="550px"><tspan> </tspan><tspan class="fg-cyan bold">--keep-going</tspan><tspan> Do not abort the build as soon as there is an error</tspan>
|
||||
<tspan x="10px" y="550px"><tspan class="fg-green bold">Compilation Options:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="568px"><tspan> </tspan><tspan class="fg-cyan bold">--target</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan"><TRIPLE></tspan><tspan class="fg-cyan">]</tspan><tspan> Build for the target triple</tspan>
|
||||
<tspan x="10px" y="568px"><tspan> </tspan><tspan class="fg-cyan bold">-j</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--jobs</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><N></tspan><tspan> Number of parallel jobs, defaults to # of CPUs.</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="586px"><tspan> </tspan><tspan class="fg-cyan bold">--target-dir</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><DIRECTORY></tspan><tspan> Directory for all generated artifacts</tspan>
|
||||
<tspan x="10px" y="586px"><tspan> </tspan><tspan class="fg-cyan bold">--keep-going</tspan><tspan> Do not abort the build as soon as there is an error</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="604px">
|
||||
<tspan x="10px" y="604px"><tspan> </tspan><tspan class="fg-cyan bold">--target</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan"><TRIPLE></tspan><tspan class="fg-cyan">]</tspan><tspan> Build for the target triple</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="622px"><tspan class="fg-green bold">Manifest Options:</tspan>
|
||||
<tspan x="10px" y="622px"><tspan> </tspan><tspan class="fg-cyan bold">--target-dir</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><DIRECTORY></tspan><tspan> Directory for all generated artifacts</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="640px"><tspan> </tspan><tspan class="fg-cyan bold">--manifest-path</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Path to Cargo.toml</tspan>
|
||||
<tspan x="10px" y="640px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="658px"><tspan> </tspan><tspan class="fg-cyan bold">--lockfile-path</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Path to Cargo.lock (unstable)</tspan>
|
||||
<tspan x="10px" y="658px"><tspan class="fg-green bold">Manifest Options:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="676px"><tspan> </tspan><tspan class="fg-cyan bold">--locked</tspan><tspan> Assert that `Cargo.lock` will remain unchanged</tspan>
|
||||
<tspan x="10px" y="676px"><tspan> </tspan><tspan class="fg-cyan bold">--manifest-path</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Path to Cargo.toml</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="694px"><tspan> </tspan><tspan class="fg-cyan bold">--offline</tspan><tspan> Run without accessing the network</tspan>
|
||||
<tspan x="10px" y="694px"><tspan> </tspan><tspan class="fg-cyan bold">--lockfile-path</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Path to Cargo.lock (unstable)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="712px"><tspan> </tspan><tspan class="fg-cyan bold">--frozen</tspan><tspan> Equivalent to specifying both --locked and --offline</tspan>
|
||||
<tspan x="10px" y="712px"><tspan> </tspan><tspan class="fg-cyan bold">--locked</tspan><tspan> Assert that `Cargo.lock` will remain unchanged</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="730px">
|
||||
<tspan x="10px" y="730px"><tspan> </tspan><tspan class="fg-cyan bold">--offline</tspan><tspan> Run without accessing the network</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="748px"><tspan>Run `</tspan><tspan class="fg-cyan bold">cargo help publish</tspan><tspan class="bold">` for more detailed information.</tspan>
|
||||
<tspan x="10px" y="748px"><tspan> </tspan><tspan class="fg-cyan bold">--frozen</tspan><tspan> Equivalent to specifying both --locked and --offline</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="766px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="784px"><tspan>Run `</tspan><tspan class="fg-cyan bold">cargo help publish</tspan><tspan class="bold">` for more detailed information.</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="802px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.9 KiB |
@ -3384,13 +3384,20 @@ fn package_selection() {
|
||||
p.cargo("publish --no-verify --dry-run -Zpackage-workspace --workspace")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.masquerade_as_nightly_cargo(&["package-workspace"])
|
||||
.with_status(1)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] unexpected argument '--workspace' found
|
||||
|
||||
Usage: cargo publish --no-verify --dry-run -Z <FLAG>
|
||||
|
||||
For more information, try '--help'.
|
||||
[UPDATING] crates.io index
|
||||
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
[PACKAGING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
[PACKAGING] b v0.1.0 ([ROOT]/foo/b)
|
||||
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||
[UPLOADING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[WARNING] aborting upload due to dry run
|
||||
[UPLOADING] b v0.1.0 ([ROOT]/foo/b)
|
||||
[WARNING] aborting upload due to dry run
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
@ -3399,13 +3406,20 @@ For more information, try '--help'.
|
||||
p.cargo("publish --no-verify --dry-run -Zpackage-workspace --package a --package b")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.masquerade_as_nightly_cargo(&["package-workspace"])
|
||||
.with_status(1)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] the argument '--package [<SPEC>]' cannot be used multiple times
|
||||
|
||||
Usage: cargo publish [OPTIONS]
|
||||
|
||||
For more information, try '--help'.
|
||||
[UPDATING] crates.io index
|
||||
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
[PACKAGING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
[PACKAGING] b v0.1.0 ([ROOT]/foo/b)
|
||||
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||
[UPLOADING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[WARNING] aborting upload due to dry run
|
||||
[UPLOADING] b v0.1.0 ([ROOT]/foo/b)
|
||||
[WARNING] aborting upload due to dry run
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
@ -3414,13 +3428,14 @@ For more information, try '--help'.
|
||||
p.cargo("publish --no-verify --dry-run -Zpackage-workspace --workspace --exclude b")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.masquerade_as_nightly_cargo(&["package-workspace"])
|
||||
.with_status(1)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] unexpected argument '--workspace' found
|
||||
|
||||
Usage: cargo publish --no-verify --dry-run -Z <FLAG>
|
||||
|
||||
For more information, try '--help'.
|
||||
[UPDATING] crates.io index
|
||||
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
[PACKAGING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
|
||||
[UPLOADING] a v0.1.0 ([ROOT]/foo/a)
|
||||
[WARNING] aborting upload due to dry run
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
@ -3428,13 +3443,11 @@ For more information, try '--help'.
|
||||
|
||||
p.cargo("publish --no-verify --dry-run --package a --package b")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.with_status(1)
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] the argument '--package [<SPEC>]' cannot be used multiple times
|
||||
|
||||
Usage: cargo publish [OPTIONS]
|
||||
|
||||
For more information, try '--help'.
|
||||
[ERROR] the `--package (multiple occurrences)` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
|
||||
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
|
||||
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--package (multiple occurrences)` flag.
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
@ -3442,13 +3455,11 @@ For more information, try '--help'.
|
||||
|
||||
p.cargo("publish --no-verify --dry-run --workspace")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.with_status(1)
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] unexpected argument '--workspace' found
|
||||
|
||||
Usage: cargo publish --no-verify --dry-run
|
||||
|
||||
For more information, try '--help'.
|
||||
[ERROR] the `--workspace` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
|
||||
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
|
||||
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--workspace` flag.
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
@ -3456,13 +3467,11 @@ For more information, try '--help'.
|
||||
|
||||
p.cargo("publish --no-verify --dry-run --exclude b")
|
||||
.replace_crates_io(registry.index_url())
|
||||
.with_status(1)
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] unexpected argument '--exclude' found
|
||||
|
||||
Usage: cargo publish --no-verify --dry-run
|
||||
|
||||
For more information, try '--help'.
|
||||
[ERROR] the `--exclude` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
|
||||
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
|
||||
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--exclude` flag.
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#""#]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user