Skip to content

Commit cd2f63b

Browse files
oech3oech3
authored andcommitted
hashsum, cksum: Move --ckeck confliction to clap
1 parent 44e0bba commit cd2f63b

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
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(

src/uu/hashsum/src/hashsum.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
171171
);
172172

173173
if check {
174-
// on Windows, allow --binary/--text to be used with --check
175-
// and keep the behavior of defaulting to binary
176-
#[cfg(not(windows))]
177-
{
178-
let text_flag = matches.get_flag("text");
179-
let binary_flag = matches.get_flag("binary");
180-
181-
if binary_flag || text_flag {
182-
return Err(ChecksumError::BinaryTextConflict.into());
183-
}
184-
}
185-
174+
// No reason to allow --check with --binary/--text on Cygwin. It want to be same with Linux and --text was broken for a long time.
186175
let verbose = ChecksumVerbose::new(status, quiet, warn);
187176

188177
let opts = ChecksumValidateOptions {
@@ -261,7 +250,9 @@ pub fn uu_app_common() -> Command {
261250
.long("check")
262251
.help(translate!("hashsum-help-check"))
263252
.action(ArgAction::SetTrue)
264-
.conflicts_with("tag"),
253+
.conflicts_with(options::BINARY)
254+
.conflicts_with(options::TEXT)
255+
.conflicts_with(options::TAG),
265256
)
266257
.arg(
267258
Arg::new(options::TAG)

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)