@@ -140,19 +140,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
140140
141141 let check = matches. get_flag ( options:: CHECK ) ;
142142
143- let check_flag = |flag| match ( check, matches. get_flag ( flag) ) {
144- ( _, false ) => Ok ( false ) ,
145- ( true , true ) => Ok ( true ) ,
146- ( false , true ) => Err ( ChecksumError :: CheckOnlyFlag ( flag. into ( ) ) ) ,
147- } ;
148-
149- // Each of the following flags are only expected in --check mode.
150- // If we encounter them otherwise, end with an error.
151- let ignore_missing = check_flag ( options:: IGNORE_MISSING ) ?;
152- let warn = check_flag ( options:: WARN ) ?;
153- let quiet = check_flag ( options:: QUIET ) ?;
154- let strict = check_flag ( options:: STRICT ) ?;
155- let status = check_flag ( options:: STATUS ) ?;
143+ let ignore_missing = matches. get_flag ( options:: IGNORE_MISSING ) ;
144+ let warn = matches. get_flag ( options:: WARN ) ;
145+ let quiet = matches. get_flag ( options:: QUIET ) ;
146+ let strict = matches. get_flag ( options:: STRICT ) ;
147+ let status = matches. get_flag ( options:: STATUS ) ;
156148
157149 let algo_cli = matches
158150 . get_one :: < String > ( options:: ALGORITHM )
@@ -284,7 +276,8 @@ pub fn uu_app() -> Command {
284276 Arg :: new ( options:: STRICT )
285277 . long ( options:: STRICT )
286278 . help ( translate ! ( "cksum-help-strict" ) )
287- . action ( ArgAction :: SetTrue ) ,
279+ . action ( ArgAction :: SetTrue )
280+ . requires ( options:: CHECK ) ,
288281 )
289282 . arg (
290283 Arg :: new ( options:: CHECK )
@@ -324,27 +317,31 @@ pub fn uu_app() -> Command {
324317 . long ( "warn" )
325318 . help ( translate ! ( "cksum-help-warn" ) )
326319 . action ( ArgAction :: SetTrue )
327- . overrides_with_all ( [ options:: STATUS , options:: QUIET ] ) ,
320+ . overrides_with_all ( [ options:: STATUS , options:: QUIET ] )
321+ . requires ( options:: CHECK ) ,
328322 )
329323 . arg (
330324 Arg :: new ( options:: STATUS )
331325 . long ( "status" )
332326 . help ( translate ! ( "cksum-help-status" ) )
333327 . action ( ArgAction :: SetTrue )
334- . overrides_with_all ( [ options:: WARN , options:: QUIET ] ) ,
328+ . overrides_with_all ( [ options:: WARN , options:: QUIET ] )
329+ . requires ( options:: CHECK ) ,
335330 )
336331 . arg (
337332 Arg :: new ( options:: QUIET )
338333 . long ( options:: QUIET )
339334 . help ( translate ! ( "cksum-help-quiet" ) )
340335 . action ( ArgAction :: SetTrue )
341- . overrides_with_all ( [ options:: WARN , options:: STATUS ] ) ,
336+ . overrides_with_all ( [ options:: WARN , options:: STATUS ] )
337+ . requires ( options:: CHECK ) ,
342338 )
343339 . arg (
344340 Arg :: new ( options:: IGNORE_MISSING )
345341 . long ( options:: IGNORE_MISSING )
346342 . help ( translate ! ( "cksum-help-ignore-missing" ) )
347- . action ( ArgAction :: SetTrue ) ,
343+ . action ( ArgAction :: SetTrue )
344+ . requires ( options:: CHECK ) ,
348345 )
349346 . arg (
350347 Arg :: new ( options:: ZERO )
0 commit comments