cksum: move the code where needed

This commit is contained in:
Sylvestre Ledru 2024-06-24 22:03:59 +02:00
parent 6a489f5ee7
commit 3b607f1c7c

View file

@ -207,16 +207,9 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
binary_flag_default
};
let check = matches.get_flag("check");
let tag = matches.get_flag("tag");
let nonames = *matches
.try_get_one("no-names")
.unwrap_or(None)
.unwrap_or(&false);
let status = matches.get_flag("status");
let quiet = matches.get_flag("quiet") || status;
//let strict = matches.get_flag("strict");
let warn = matches.get_flag("warn") && !status;
let zero = matches.get_flag("zero");
let ignore_missing = matches.get_flag("ignore-missing");
if ignore_missing && !check {
@ -224,22 +217,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
return Err(ChecksumError::IgnoreNotCheck.into());
}
let opts = Options {
algoname: algo.name,
digest: (algo.create_fn)(),
output_bits: algo.bits,
binary,
//check,
tag,
nonames,
//status,
//quiet,
//strict,
//warn,
zero,
//ignore_missing,
};
if check {
let text_flag = matches.get_flag("text");
let binary_flag = matches.get_flag("binary");
@ -270,6 +247,26 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
);
}
let nonames = *matches
.try_get_one("no-names")
.unwrap_or(None)
.unwrap_or(&false);
let zero = matches.get_flag("zero");
let opts = Options {
algoname: algo.name,
digest: (algo.create_fn)(),
output_bits: algo.bits,
binary,
tag: matches.get_flag("tag"),
nonames,
//status,
//quiet,
//warn,
zero,
//ignore_missing,
};
// Show the hashsum of the input
match matches.get_many::<OsString>(options::FILE) {
Some(files) => hashsum(opts, files.map(|f| f.as_os_str())),