Skip to content

Commit 1defff9

Browse files
authored
numfmt: move duplicate code to function (#11381)
1 parent 7609966 commit 1defff9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/uu/numfmt/src/numfmt.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,26 +318,22 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
318318
}
319319

320320
fn print_debug_warnings(options: &NumfmtOptions, matches: &ArgMatches) {
321+
fn print_warning(msg_key: &str) {
322+
let _ = writeln!(stderr(), "numfmt: {}", translate!(msg_key));
323+
}
324+
321325
// Warn if no conversion option is specified
322326
// 2>/dev/full does not abort
323327
if options.transform.from == Unit::None
324328
&& options.transform.to == Unit::None
325329
&& options.padding == 0
326330
{
327-
let _ = writeln!(
328-
stderr(),
329-
"numfmt: {}",
330-
translate!("numfmt-debug-no-conversion")
331-
);
331+
print_warning("numfmt-debug-no-conversion");
332332
}
333333

334334
// Warn if --header is used with command-line input
335335
if options.header > 0 && matches.get_many::<OsString>(NUMBER).is_some() {
336-
let _ = writeln!(
337-
stderr(),
338-
"numfmt: {}",
339-
translate!("numfmt-debug-header-ignored")
340-
);
336+
print_warning("numfmt-debug-header-ignored");
341337
}
342338
}
343339

0 commit comments

Comments
 (0)