Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/uu/factor/locales/en-US.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
factor-about = Print the prime factors of the given NUMBER(s).
If none are specified, read from standard input.
factor-usage = factor [OPTION]... [NUMBER]...

# Help messages
factor-help-exponents = Print factors in the form p^e
factor-help-help = Print help information.

# Error messages
factor-error-factorization-incomplete = Factorization incomplete. Remainders exists.
factor-error-write-error = write error
factor-error-reading-input = error reading input: { $error }
12 changes: 12 additions & 0 deletions src/uu/factor/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
factor-about = Afficher les facteurs premiers du/des NOMBRE(s) donné(s).
Si aucun n'est spécifié, lire depuis l'entrée standard.
factor-usage = factor [OPTION]... [NOMBRE]...

# Messages d'aide
factor-help-exponents = Afficher les facteurs sous la forme p^e
factor-help-help = Afficher les informations d'aide.

# Messages d'erreur
factor-error-factorization-incomplete = Factorisation incomplète. Des restes existent.
factor-error-write-error = erreur d'écriture
factor-error-reading-input = erreur de lecture de l'entrée : { $error }
21 changes: 14 additions & 7 deletions src/uu/factor/src/factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// spell-checker:ignore funcs

use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};
use std::io::BufRead;
use std::io::{self, Write, stdin, stdout};

Expand All @@ -16,7 +16,7 @@
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
use uucore::{format_usage, show_error, show_warning};

use uucore::locale::get_message;
use uucore::locale::{get_message, get_message_with_args};

mod options {
pub static EXPONENTS: &str = "exponents";
Expand Down Expand Up @@ -46,11 +46,12 @@
if let Some(_remaining) = remaining {
return Err(USimpleError::new(
1,
"Factorization incomplete. Remainders exists.",
get_message("factor-error-factorization-incomplete"),

Check warning on line 49 in src/uu/factor/src/factor.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/factor/src/factor.rs#L49

Added line #L49 was not covered by tests
));
}

write_result(w, &x, factorization, print_exponents).map_err_context(|| "write error".into())?;
write_result(w, &x, factorization, print_exponents)
.map_err_context(|| get_message("factor-error-write-error"))?;

Ok(())
}
Expand Down Expand Up @@ -104,7 +105,13 @@
}
Err(e) => {
set_exit_code(1);
show_error!("error reading input: {e}");
show_error!(
"{}",
get_message_with_args(
"factor-error-reading-input",
HashMap::from([("error".to_string(), e.to_string())])

Check warning on line 112 in src/uu/factor/src/factor.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/factor/src/factor.rs#L108-L112

Added lines #L108 - L112 were not covered by tests
)
);
return Ok(());
}
}
Expand All @@ -131,13 +138,13 @@
Arg::new(options::EXPONENTS)
.short('h')
.long(options::EXPONENTS)
.help("Print factors in the form p^e")
.help(get_message("factor-help-exponents"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::HELP)
.long(options::HELP)
.help("Print help information.")
.help(get_message("factor-help-help"))
.action(ArgAction::Help),
)
}
Loading