Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

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

let length = maybe_sanitize_length(algo_cli, input_length)?;

let files = matches.get_many::<OsString>(options::FILE).map_or_else(
// No files given, read from stdin.
|| Box::new(iter::once(OsStr::new("-"))) as Box<dyn Iterator<Item = &OsStr>>,
// At least one file given, read from them.
|files| Box::new(files.map(OsStr::new)) as Box<dyn Iterator<Item = &OsStr>>,
);
// clap provides the default value -. So we unwrap() safety.
let files = matches
.get_many::<OsString>(options::FILE)
.unwrap()
.map(|s| s.as_os_str());

if check {
// cksum does not support '--check'ing legacy algorithms
Expand Down Expand Up @@ -200,6 +198,8 @@ pub fn uu_app() -> Command {
.hide(true)
.action(ArgAction::Append)
.value_parser(ValueParser::os_string())
.default_value("-")
.hide_default_value(true)
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Expand Down
13 changes: 7 additions & 6 deletions src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,11 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
let strict = matches.get_flag("strict");
let status = matches.get_flag("status");

let files = matches.get_many::<OsString>(options::FILE).map_or_else(
// No files given, read from stdin.
|| Box::new(iter::once(OsStr::new("-"))) as Box<dyn Iterator<Item = &OsStr>>,
// At least one file given, read from them.
|files| Box::new(files.map(OsStr::new)) as Box<dyn Iterator<Item = &OsStr>>,
);
// clap provides the default value -. So we unwrap() safety.
let files = matches
.get_many::<OsString>(options::FILE)
.unwrap()
.map(|s| s.as_os_str());

if check {
// on Windows, allow --binary/--text to be used with --check
Expand Down Expand Up @@ -340,6 +339,8 @@ pub fn uu_app_common() -> Command {
.index(1)
.action(ArgAction::Append)
.value_name(options::FILE)
.default_value("-")
.hide_default_value(true)
.value_hint(clap::ValueHint::FilePath)
.value_parser(ValueParser::os_string()),
)
Expand Down
Loading