1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

timeout: tests passing.

Forgot to handle the case where no arguments were passed to the COMMAND.
Because ARGS can be empty, we need two separate cases for handling
options.values_of(options::ARGS)
This commit is contained in:
Ricardo Iglesias 2021-04-06 23:30:15 -07:00
parent 431a6ee1b5
commit 8232c527a3

View file

@ -79,11 +79,11 @@ impl Config {
let foreground = options.is_present(options::FOREGROUND);
let command: String = options.value_of(options::COMMAND).unwrap().to_string();
let command_args: Vec<String> = options
.values_of(options::ARGS)
.unwrap()
.map(|x| x.to_owned())
.collect();
let command_args: Vec<String> = match options.values_of(options::ARGS) {
Some(values) => values.map(|x| x.to_owned()).collect(),
None => vec![],
};
Config {
foreground,
@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.required(true)
)
.arg(
Arg::with_name(options::ARGS).required(true).multiple(true)
Arg::with_name(options::ARGS).multiple(true)
)
.setting(AppSettings::TrailingVarArg);