Skip to content

Commit

Permalink
refactor: Resolve clap deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 28, 2022
1 parent 4b10c40 commit 2084f5c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use cargo::ops::{self, TestOptions};

pub fn cli() -> Command {
subcommand("bench")
.trailing_var_arg(true)
.about("Execute all benchmarks of a local package")
.arg_quiet()
.arg(
Expand All @@ -14,7 +13,8 @@ pub fn cli() -> Command {
.arg(
Arg::new("args")
.help("Arguments for the bench binary")
.num_args(0..),
.num_args(0..)
.trailing_var_arg(true),
)
.arg_targets_all(
"Benchmark only this package's library",
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ pub fn cli() -> Command {
subcommand("run")
// subcommand aliases are handled in aliased_command()
// .alias("r")
.trailing_var_arg(true)
.about("Run a binary or example of the local package")
.arg_quiet()
.arg(
Arg::new("args")
.value_parser(value_parser!(std::ffi::OsString))
.num_args(0..),
.num_args(0..)
.trailing_var_arg(true),
)
.arg_targets_bin_example(
"Name of the bin target to run",
Expand Down
8 changes: 6 additions & 2 deletions src/bin/cargo/commands/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ const CRATE_TYPE_ARG_NAME: &str = "crate-type";

pub fn cli() -> Command {
subcommand("rustc")
.trailing_var_arg(true)
.about("Compile a package, and pass extra options to the compiler")
.arg_quiet()
.arg(Arg::new("args").num_args(0..).help("Rustc flags"))
.arg(
Arg::new("args")
.num_args(0..)
.help("Rustc flags")
.trailing_var_arg(true),
)
.arg_package("Package to build")
.arg_jobs()
.arg_targets_all(
Expand Down
3 changes: 1 addition & 2 deletions src/bin/cargo/commands/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use crate::command_prelude::*;

pub fn cli() -> Command {
subcommand("rustdoc")
.trailing_var_arg(true)
.about("Build a package's documentation, using specified custom flags.")
.arg_quiet()
.arg(Arg::new("args").num_args(0..))
.arg(Arg::new("args").num_args(0..).trailing_var_arg(true))
.arg(flag(
"open",
"Opens the docs in a browser after the operation",
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub fn cli() -> Command {
subcommand("test")
// Subcommand aliases are handled in `aliased_command()`.
// .alias("t")
.trailing_var_arg(true)
.about("Execute all unit and integration tests and build examples of a local package")
.arg(
Arg::new("TESTNAME")
Expand All @@ -15,7 +14,8 @@ pub fn cli() -> Command {
.arg(
Arg::new("args")
.help("Arguments for the test binary")
.num_args(0..),
.num_args(0..)
.trailing_var_arg(true),
)
.arg(
flag(
Expand Down

0 comments on commit 2084f5c

Please sign in to comment.