From 9986cfe19d74feb0faf085394d5db65bd03c79a3 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Sat, 11 Jul 2026 16:50:07 +0900 Subject: [PATCH] head: set default of FILE to - by clap --- src/uu/head/src/cli.rs | 1 + src/uu/head/src/head.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/uu/head/src/cli.rs b/src/uu/head/src/cli.rs index 823d3869116..ed308ffbf91 100644 --- a/src/uu/head/src/cli.rs +++ b/src/uu/head/src/cli.rs @@ -79,6 +79,7 @@ pub fn uu_app() -> Command { Arg::new(options::FILES) .action(ArgAction::Append) .value_parser(clap::value_parser!(OsString)) + .default_value("-") .value_hint(clap::ValueHint::FilePath), ) } diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 955b3334dfd..24ff9e5c045 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -150,11 +150,12 @@ impl HeadOptions { options.presume_input_pipe = matches.get_flag(options::PRESUME_INPUT_PIPE); options.mode = Mode::from(matches)?; - - options.files = match matches.get_many::(options::FILES) { - Some(v) => v.cloned().collect(), - None => vec![OsString::from("-")], - }; + // #[allow(clippy::unwrap_used, reason = "clap provides '-' by default")] + options.files = matches + .get_many::(options::FILES) + .unwrap() + .cloned() + .collect(); Ok(options) }