1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-18 04:36:18 +00:00

env: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 13:27:00 +01:00
parent 812f2db464
commit 4d917e28b2
2 changed files with 16 additions and 16 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/env.rs" path = "src/env.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42" libc = "0.2.42"
rust-ini = "0.17.0" rust-ini = "0.17.0"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }

30
src/uu/env/src/env.rs vendored
View file

@ -119,46 +119,46 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b
(progname, &args[..]) (progname, &args[..])
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new(crate_name!()) App::new(crate_name!())
.version(crate_version!()) .version(crate_version!())
.author(crate_authors!()) .author(crate_authors!())
.about(crate_description!()) .about(crate_description!())
.usage(USAGE) .override_usage(USAGE)
.after_help(AFTER_HELP) .after_help(AFTER_HELP)
.setting(AppSettings::AllowExternalSubcommands) .setting(AppSettings::AllowExternalSubcommands)
.arg(Arg::with_name("ignore-environment") .arg(Arg::new("ignore-environment")
.short("i") .short('i')
.long("ignore-environment") .long("ignore-environment")
.help("start with an empty environment")) .help("start with an empty environment"))
.arg(Arg::with_name("chdir") .arg(Arg::new("chdir")
.short("C") // GNU env compatibility .short('C') // GNU env compatibility
.long("chdir") .long("chdir")
.takes_value(true) .takes_value(true)
.number_of_values(1) .number_of_values(1)
.value_name("DIR") .value_name("DIR")
.help("change working directory to DIR")) .help("change working directory to DIR"))
.arg(Arg::with_name("null") .arg(Arg::new("null")
.short("0") .short('0')
.long("null") .long("null")
.help("end each output line with a 0 byte rather than a newline (only valid when \ .help("end each output line with a 0 byte rather than a newline (only valid when \
printing the environment)")) printing the environment)"))
.arg(Arg::with_name("file") .arg(Arg::new("file")
.short("f") .short('f')
.long("file") .long("file")
.takes_value(true) .takes_value(true)
.number_of_values(1) .number_of_values(1)
.value_name("PATH") .value_name("PATH")
.multiple(true) .multiple_occurrences(true)
.help("read and set variables from a \".env\"-style configuration file (prior to any \ .help("read and set variables from a \".env\"-style configuration file (prior to any \
unset and/or set)")) unset and/or set)"))
.arg(Arg::with_name("unset") .arg(Arg::new("unset")
.short("u") .short('u')
.long("unset") .long("unset")
.takes_value(true) .takes_value(true)
.number_of_values(1) .number_of_values(1)
.value_name("NAME") .value_name("NAME")
.multiple(true) .multiple_occurrences(true)
.help("remove variable from the environment")) .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 // we handle the name, value pairs and the program to be executed by treating them as external
// subcommands in clap // subcommands in clap
if let (external, Some(matches)) = matches.subcommand() { if let Some((external, matches)) = matches.subcommand() {
let mut begin_prog_opts = false; let mut begin_prog_opts = false;
if external == "-" { if external == "-" {