|
7 | 7 |
|
8 | 8 | use clap::builder::ValueParser; |
9 | 9 | use clap::{Arg, ArgAction, Command}; |
10 | | -use std::ffi::{OsStr, OsString}; |
11 | | -use std::iter; |
| 10 | +use std::ffi::OsString; |
12 | 11 | use uucore::checksum::compute::{ |
13 | 12 | ChecksumComputeOptions, figure_out_output_format, perform_checksum_computation, |
14 | 13 | }; |
@@ -121,12 +120,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { |
121 | 120 |
|
122 | 121 | let length = maybe_sanitize_length(algo_cli, input_length)?; |
123 | 122 |
|
124 | | - let files = matches.get_many::<OsString>(options::FILE).map_or_else( |
125 | | - // No files given, read from stdin. |
126 | | - || Box::new(iter::once(OsStr::new("-"))) as Box<dyn Iterator<Item = &OsStr>>, |
127 | | - // At least one file given, read from them. |
128 | | - |files| Box::new(files.map(OsStr::new)) as Box<dyn Iterator<Item = &OsStr>>, |
129 | | - ); |
| 123 | + // We unwrap() stdin given by clap at least for |
| 124 | + let files = matches |
| 125 | + .get_many::<OsString>(options::FILE) |
| 126 | + .unwrap() |
| 127 | + .map(|s| s.as_os_str()); |
130 | 128 |
|
131 | 129 | if check { |
132 | 130 | // cksum does not support '--check'ing legacy algorithms |
@@ -200,6 +198,8 @@ pub fn uu_app() -> Command { |
200 | 198 | .hide(true) |
201 | 199 | .action(ArgAction::Append) |
202 | 200 | .value_parser(ValueParser::os_string()) |
| 201 | + .default_value("-") |
| 202 | + .hide_default_value(true) |
203 | 203 | .value_hint(clap::ValueHint::FilePath), |
204 | 204 | ) |
205 | 205 | .arg( |
|
0 commit comments