1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-03 06:27:45 +00:00

timeout: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 15:08:45 +01:00
parent 0ff1984471
commit 7318d1d24b
2 changed files with 14 additions and 14 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/timeout.rs" path = "src/timeout.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"
nix = "0.23.1" nix = "0.23.1"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["process", "signals"] } uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["process", "signals"] }

View file

@ -108,7 +108,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage(); let usage = usage();
let app = uu_app().usage(&usage[..]); let app = uu_app().override_usage(&usage[..]);
let matches = app.get_matches_from(args); let matches = app.get_matches_from(args);
@ -124,47 +124,47 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
) )
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new("timeout") App::new("timeout")
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.arg( .arg(
Arg::with_name(options::FOREGROUND) Arg::new(options::FOREGROUND)
.long(options::FOREGROUND) .long(options::FOREGROUND)
.help("when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out") .help("when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out")
) )
.arg( .arg(
Arg::with_name(options::KILL_AFTER) Arg::new(options::KILL_AFTER)
.short("k") .short('k')
.takes_value(true)) .takes_value(true))
.arg( .arg(
Arg::with_name(options::PRESERVE_STATUS) Arg::new(options::PRESERVE_STATUS)
.long(options::PRESERVE_STATUS) .long(options::PRESERVE_STATUS)
.help("exit with the same status as COMMAND, even when the command times out") .help("exit with the same status as COMMAND, even when the command times out")
) )
.arg( .arg(
Arg::with_name(options::SIGNAL) Arg::new(options::SIGNAL)
.short("s") .short('s')
.long(options::SIGNAL) .long(options::SIGNAL)
.help("specify the signal to be sent on timeout; SIGNAL may be a name like 'HUP' or a number; see 'kill -l' for a list of signals") .help("specify the signal to be sent on timeout; SIGNAL may be a name like 'HUP' or a number; see 'kill -l' for a list of signals")
.takes_value(true) .takes_value(true)
) )
.arg( .arg(
Arg::with_name(options::VERBOSE) Arg::new(options::VERBOSE)
.short("v") .short('v')
.long(options::VERBOSE) .long(options::VERBOSE)
.help("diagnose to stderr any signal sent upon timeout") .help("diagnose to stderr any signal sent upon timeout")
) )
.arg( .arg(
Arg::with_name(options::DURATION) Arg::new(options::DURATION)
.index(1) .index(1)
.required(true) .required(true)
) )
.arg( .arg(
Arg::with_name(options::COMMAND) Arg::new(options::COMMAND)
.index(2) .index(2)
.required(true) .required(true)
.multiple(true) .multiple_occurrences(true)
) )
.setting(AppSettings::TrailingVarArg) .setting(AppSettings::TrailingVarArg)
} }