From 4d917e28b281c53e5d71ae29cdc3bacc4c7f2cd0 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 13:27:00 +0100 Subject: [PATCH] env: clap 3 --- src/uu/env/Cargo.toml | 2 +- src/uu/env/src/env.rs | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index 374a4eda9..66a7fba1d 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/env.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" rust-ini = "0.17.0" uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 55dfce625..639887ee0 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -119,46 +119,46 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b (progname, &args[..]) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) - .usage(USAGE) + .override_usage(USAGE) .after_help(AFTER_HELP) .setting(AppSettings::AllowExternalSubcommands) - .arg(Arg::with_name("ignore-environment") - .short("i") + .arg(Arg::new("ignore-environment") + .short('i') .long("ignore-environment") .help("start with an empty environment")) - .arg(Arg::with_name("chdir") - .short("C") // GNU env compatibility + .arg(Arg::new("chdir") + .short('C') // GNU env compatibility .long("chdir") .takes_value(true) .number_of_values(1) .value_name("DIR") .help("change working directory to DIR")) - .arg(Arg::with_name("null") - .short("0") + .arg(Arg::new("null") + .short('0') .long("null") .help("end each output line with a 0 byte rather than a newline (only valid when \ printing the environment)")) - .arg(Arg::with_name("file") - .short("f") + .arg(Arg::new("file") + .short('f') .long("file") .takes_value(true) .number_of_values(1) .value_name("PATH") - .multiple(true) + .multiple_occurrences(true) .help("read and set variables from a \".env\"-style configuration file (prior to any \ unset and/or set)")) - .arg(Arg::with_name("unset") - .short("u") + .arg(Arg::new("unset") + .short('u') .long("unset") .takes_value(true) .number_of_values(1) .value_name("NAME") - .multiple(true) + .multiple_occurrences(true) .help("remove variable from the environment")) } @@ -203,7 +203,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { // we handle the name, value pairs and the program to be executed by treating them as external // subcommands in clap - if let (external, Some(matches)) = matches.subcommand() { + if let Some((external, matches)) = matches.subcommand() { let mut begin_prog_opts = false; if external == "-" {