@@ -262,6 +262,8 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
262262
263263 let zero_terminated = args. get_flag ( ZERO_TERMINATED ) ;
264264
265+ let debug = args. get_flag ( DEBUG ) ;
266+
265267 Ok ( NumfmtOptions {
266268 transform,
267269 padding,
@@ -274,15 +276,35 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
274276 format,
275277 invalid,
276278 zero_terminated,
279+ debug,
277280 } )
278281}
279282
283+ fn print_debug_warnings ( options : & NumfmtOptions , matches : & ArgMatches ) {
284+ // Warn if no conversion option is specified
285+ if options. transform . from == Unit :: None
286+ && options. transform . to == Unit :: None
287+ && options. padding == 0
288+ {
289+ show_error ! ( "{}" , translate!( "numfmt-debug-no-conversion" ) ) ;
290+ }
291+
292+ // Warn if --header is used with command-line input
293+ if options. header > 0 && matches. get_many :: < OsString > ( NUMBER ) . is_some ( ) {
294+ show_error ! ( "{}" , translate!( "numfmt-debug-header-ignored" ) ) ;
295+ }
296+ }
297+
280298#[ uucore:: main]
281299pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
282300 let matches = uucore:: clap_localization:: handle_clap_result ( uu_app ( ) , args) ?;
283301
284302 let options = parse_options ( & matches) . map_err ( NumfmtError :: IllegalArgument ) ?;
285303
304+ if options. debug {
305+ print_debug_warnings ( & options, & matches) ;
306+ }
307+
286308 let result = match matches. get_many :: < OsString > ( NUMBER ) {
287309 Some ( values) => {
288310 let byte_args: Vec < & [ u8 ] > = values
@@ -316,6 +338,12 @@ pub fn uu_app() -> Command {
316338 . override_usage ( format_usage ( & translate ! ( "numfmt-usage" ) ) )
317339 . allow_negative_numbers ( true )
318340 . infer_long_args ( true )
341+ . arg (
342+ Arg :: new ( DEBUG )
343+ . long ( DEBUG )
344+ . help ( translate ! ( "numfmt-help-debug" ) )
345+ . action ( ArgAction :: SetTrue ) ,
346+ )
319347 . arg (
320348 Arg :: new ( DELIMITER )
321349 . short ( 'd' )
@@ -466,6 +494,7 @@ mod tests {
466494 format : FormatOptions :: default ( ) ,
467495 invalid : InvalidModes :: Abort ,
468496 zero_terminated : false ,
497+ debug : false ,
469498 }
470499 }
471500
0 commit comments