Skip to content

Commit 0f202ca

Browse files
oech3oech3
authored andcommitted
cksum: Move default stdin to clap
1 parent 8cf88cd commit 0f202ca

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/uu/cksum/src/cksum.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
use clap::builder::ValueParser;
99
use clap::{Arg, ArgAction, Command};
10-
use std::ffi::{OsStr, OsString};
11-
use std::iter;
10+
use std::ffi::OsString;
1211
use uucore::checksum::compute::{
1312
ChecksumComputeOptions, figure_out_output_format, perform_checksum_computation,
1413
};
@@ -121,12 +120,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
121120

122121
let length = maybe_sanitize_length(algo_cli, input_length)?;
123122

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());
130128

131129
if check {
132130
// cksum does not support '--check'ing legacy algorithms
@@ -200,6 +198,8 @@ pub fn uu_app() -> Command {
200198
.hide(true)
201199
.action(ArgAction::Append)
202200
.value_parser(ValueParser::os_string())
201+
.default_value("-")
202+
.hide_default_value(true)
203203
.value_hint(clap::ValueHint::FilePath),
204204
)
205205
.arg(

0 commit comments

Comments
 (0)