Skip to content

Commit f54a69b

Browse files
author
oech3
committed
cksum: Move --check confliction to clap
1 parent 81ee8d1 commit f54a69b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/uu/cksum/src/cksum.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
134134
return Err(ChecksumError::AlgorithmNotSupportedWithCheck.into());
135135
}
136136

137-
let text_flag = matches.get_flag(options::TEXT);
138-
let binary_flag = matches.get_flag(options::BINARY);
139-
let tag = matches.get_flag(options::TAG);
140-
141-
if tag || binary_flag || text_flag {
142-
return Err(ChecksumError::BinaryTextConflict.into());
143-
}
144-
145137
// Execute the checksum validation based on the presence of files or the use of stdin
146138

147139
let verbose = ChecksumVerbose::new(status, quiet, warn);
@@ -251,6 +243,9 @@ pub fn uu_app() -> Command {
251243
.short('c')
252244
.long(options::CHECK)
253245
.help(translate!("cksum-help-check"))
246+
.conflicts_with(options::TAG)
247+
.conflicts_with(options::BINARY)
248+
.conflicts_with(options::TEXT)
254249
.action(ArgAction::SetTrue),
255250
)
256251
.arg(

tests/by-util/test_cksum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ fn test_conflicting_options() {
12161216
.fails_with_code(1)
12171217
.no_stdout()
12181218
.stderr_contains(
1219-
"cksum: the --binary and --text options are meaningless when verifying checksums",
1219+
"cannot be used with", //clap generated error
12201220
);
12211221

12221222
scene
@@ -1228,7 +1228,7 @@ fn test_conflicting_options() {
12281228
.fails_with_code(1)
12291229
.no_stdout()
12301230
.stderr_contains(
1231-
"cksum: the --binary and --text options are meaningless when verifying checksums",
1231+
"cannot be used with", //clap generated error
12321232
);
12331233
}
12341234

0 commit comments

Comments
 (0)