1 use crate::command_prelude::*;
2
3 use cargo::ops::{self, PublishOpts};
4
cli() -> App5 pub fn cli() -> App {
6 subcommand("publish")
7 .about("Upload a package to the registry")
8 .arg(opt("quiet", "No output printed to stdout").short("q"))
9 .arg_index()
10 .arg(opt("token", "Token to use when uploading").value_name("TOKEN"))
11 .arg(opt(
12 "no-verify",
13 "Don't verify the contents by building them",
14 ))
15 .arg(opt(
16 "allow-dirty",
17 "Allow dirty working directories to be packaged",
18 ))
19 .arg_target_triple("Build for the target triple")
20 .arg_target_dir()
21 .arg_package("Package to publish")
22 .arg_manifest_path()
23 .arg_features()
24 .arg_jobs()
25 .arg_dry_run("Perform all checks without uploading")
26 .arg(opt("registry", "Registry to publish to").value_name("REGISTRY"))
27 .after_help("Run `cargo help publish` for more detailed information.\n")
28 }
29
exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult30 pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
31 config.load_credentials()?;
32
33 let registry = args.registry(config)?;
34 let ws = args.workspace(config)?;
35 let index = args.index(config)?;
36
37 ops::publish(
38 &ws,
39 &PublishOpts {
40 config,
41 token: args.value_of("token").map(|s| s.to_string()),
42 index,
43 verify: !args.is_present("no-verify"),
44 allow_dirty: args.is_present("allow-dirty"),
45 to_publish: args.packages_from_flags()?,
46 targets: args.targets(),
47 jobs: args.jobs()?,
48 dry_run: args.is_present("dry-run"),
49 registry,
50 cli_features: args.cli_features()?,
51 },
52 )?;
53 Ok(())
54 }
55