From ec42e824f04c63cff1f1f11158b0977563244d6a Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 14:43:29 +0100 Subject: [PATCH] runcon: clap 3 --- src/uu/runcon/Cargo.toml | 2 +- src/uu/runcon/src/runcon.rs | 40 ++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index ff06e72a1..b424a876e 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" path = "src/runcon.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" } selinux = { version = "0.2" } diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 595cf3e65..38cf89c14 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -109,51 +109,59 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .after_help(DESCRIPTION) .arg( - Arg::with_name(options::COMPUTE) - .short("c") + Arg::new(options::COMPUTE) + .short('c') .long(options::COMPUTE) .takes_value(false) .help("Compute process transition context before modifying."), ) .arg( - Arg::with_name(options::USER) - .short("u") + Arg::new(options::USER) + .short('u') .long(options::USER) .takes_value(true) .value_name("USER") - .help("Set user USER in the target security context."), + .help("Set user USER in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::ROLE) - .short("r") + Arg::new(options::ROLE) + .short('r') .long(options::ROLE) .takes_value(true) .value_name("ROLE") - .help("Set role ROLE in the target security context."), + .help("Set role ROLE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::TYPE) - .short("t") + Arg::new(options::TYPE) + .short('t') .long(options::TYPE) .takes_value(true) .value_name("TYPE") - .help("Set type TYPE in the target security context."), + .help("Set type TYPE in the target security context.") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::RANGE) - .short("l") + Arg::new(options::RANGE) + .short('l') .long(options::RANGE) .takes_value(true) .value_name("RANGE") - .help("Set range RANGE in the target security context."), + .help("Set range RANGE in the target security context.") + .allow_invalid_utf8(true), + ) + .arg( + Arg::new("ARG") + .multiple_occurrences(true) + .allow_invalid_utf8(true), ) - .arg(Arg::with_name("ARG").multiple(true)) // Once "ARG" is parsed, everything after that belongs to it. // // This is not how POSIX does things, but this is how the GNU implementation