Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): Prepare for clap v4 #11116

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,14 @@ impl GlobalArgs {
}
}

pub fn cli() -> App {
pub fn cli() -> Command {
let is_rustup = std::env::var_os("RUSTUP_HOME").is_some();
let usage = if is_rustup {
"cargo [+toolchain] [OPTIONS] [SUBCOMMAND]"
} else {
"cargo [OPTIONS] [SUBCOMMAND]"
};
App::new("cargo")
Command::new("cargo")
.allow_external_subcommands(true)
.setting(AppSettings::DeriveDisplayOrder)
// Doesn't mix well with our list of common cargo commands. See clap-rs/clap#3108 for
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cargo::util::interning::InternedString;
use cargo::util::toml_mut::manifest::DepTable;
use cargo::CargoResult;

pub fn cli() -> clap::Command<'static> {
pub fn cli() -> Command {
clap::Command::new("add")
.setting(clap::AppSettings::DeriveDisplayOrder)
.about("Add dependencies to a Cargo.toml manifest file")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;
use cargo::ops::{self, TestOptions};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("bench")
.trailing_var_arg(true)
.about("Execute all benchmarks of a local package")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("build")
// subcommand aliases are handled in aliased_command()
// .alias("b")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("check")
// subcommand aliases are handled in aliased_command()
// .alias("c")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::command_prelude::*;
use cargo::ops::{self, CleanOptions};
use cargo::util::print_available_packages;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("clean")
.about("Remove artifacts that cargo has generated in the past")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;
use cargo::ops::cargo_config;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("config")
.about("Inspect configuration values")
.after_help("Run `cargo help config` for more detailed information.\n")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops::{self, DocOptions};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("doc")
// subcommand aliases are handled in aliased_command()
// .alias("d")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::command_prelude::*;
use cargo::ops;
use cargo::ops::FetchOptions;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("fetch")
.about("Fetch dependencies of a package from the network")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("fix")
.about("Automatically fix lint warnings reported by rustc")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("generate-lockfile")
.about("Generate the lockfile for a package")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/git_checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

const REMOVED: &str = "The `git-checkout` subcommand has been removed.";

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("git-checkout")
.about("This subcommand has been removed")
.hide(true)
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::Path;

const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz"));

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("help")
.about("Displays help for a cargo subcommand")
.arg(Arg::new("SUBCOMMAND"))
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("init")
.about("Create a new cargo package in an existing directory")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo::util::IntoUrl;

use cargo_util::paths;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("install")
.about("Install a Rust binary. Default location is $HOME/.cargo/bin")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/locate_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::bail;
use cargo::{drop_println, CargoResult};
use serde::Serialize;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("locate-project")
.about("Print a JSON representation of a Cargo.toml file's location")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("login")
.about(
"Save an api token from the registry locally. \
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/logout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;
use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("logout")
.about("Remove an API token from the registry locally")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;
use cargo::ops::{self, OutputMetadataOptions};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("metadata")
.about(
"Output the resolved dependencies of a package, \
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::command_prelude::*;

pub fn builtin() -> Vec<App> {
pub fn builtin() -> Vec<Command> {
vec![
add::cli(),
bench::cli(),
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("new")
.about("Create a new cargo package at <path>")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops::{self, OwnersOptions};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("owner")
.about("Manage the owners of a crate on the registry")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops::{self, PackageOpts};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("package")
.about("Assemble the local package into a distributable tarball")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/pkgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::command_prelude::*;
use cargo::ops;
use cargo::util::print_available_packages;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("pkgid")
.about("Print a fully qualified package specification")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops::{self, PublishOpts};

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("publish")
.about("Upload a package to the registry")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::command_prelude::*;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("read-manifest")
.about(
"\
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;
use cargo::core::compiler::future_incompat::{OnDiskReports, REPORT_PREAMBLE};
use cargo::drop_println;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("report")
.about("Generate and display various kinds of reports")
.after_help("Run `cargo help report` for more detailed information.\n")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cargo::core::Verbosity;
use cargo::ops::{self, CompileFilter, Packages};
use cargo_util::ProcessError;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("run")
// subcommand aliases are handled in aliased_command()
// .alias("r")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo::util::interning::InternedString;
const PRINT_ARG_NAME: &str = "print";
const CRATE_TYPE_ARG_NAME: &str = "crate-type";

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("rustc")
.trailing_var_arg(true)
.about("Compile a package, and pass extra options to the compiler")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cargo::ops::{self, DocOptions};

use crate::command_prelude::*;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("rustdoc")
.trailing_var_arg(true)
.about("Build a package's documentation, using specified custom flags.")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::cmp::min;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("search")
.about("Search packages in crates.io")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;
use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("test")
// Subcommand aliases are handled in `aliased_command()`.
// .alias("t")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cargo::util::CargoResult;
use std::collections::HashSet;
use std::str::FromStr;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("tree")
.about("Display a tree visualization of a dependency graph")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("uninstall")
.about("Remove a Rust binary")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::command_prelude::*;
use cargo::ops::{self, UpdateOptions};
use cargo::util::print_available_packages;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("update")
.about("Update dependencies as recorded in the local lock file")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;
use cargo::ops;
use std::path::PathBuf;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("vendor")
.about("Vendor all dependencies for a project locally")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/verify_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::command_prelude::*;
use std::collections::HashMap;
use std::process;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("verify-project")
.about("Check correctness of crate manifest")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cli;
use crate::command_prelude::*;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("version")
.about("Show version information")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/yank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::command_prelude::*;

use cargo::ops;

pub fn cli() -> App {
pub fn cli() -> Command {
subcommand("yank")
.about("Remove a pushed crate from the index")
.arg_quiet()
Expand Down
Loading