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/basename/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ basename-about = Print NAME with any leading directory components removed
If specified, also remove a trailing SUFFIX
basename-usage = basename [-z] NAME [SUFFIX]
basename OPTION... NAME...

# Error messages
basename-error-missing-operand = missing operand
basename-error-extra-operand = extra operand { $operand }

# Help text for command-line arguments
basename-help-multiple = support multiple arguments and treat each as a NAME
basename-help-suffix = remove a trailing SUFFIX; implies -a
basename-help-zero = end each output line with NUL, not newline
13 changes: 13 additions & 0 deletions src/uu/basename/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
basename-about = Affiche NOM sans les composants de répertoire précédents
Si spécifié, supprime également un SUFFIXE final
basename-usage = basename [-z] NOM [SUFFIXE]
basename OPTION... NOM...

# Messages d'erreur
basename-error-missing-operand = opérande manquant
basename-error-extra-operand = opérande supplémentaire { $operand }

# Texte d'aide pour les arguments de ligne de commande
basename-help-multiple = prend en charge plusieurs arguments et traite chacun comme un NOM
basename-help-suffix = supprime un SUFFIXE final ; implique -a
basename-help-zero = termine chaque ligne de sortie avec NUL, pas nouvelle ligne
19 changes: 13 additions & 6 deletions src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
// spell-checker:ignore (ToDO) fullname

use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::path::{PathBuf, is_separator};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
use uucore::format_usage;
use uucore::line_ending::LineEnding;

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

pub mod options {
pub static MULTIPLE: &str = "multiple";
Expand All @@ -37,7 +38,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.unwrap_or_default()
.collect::<Vec<_>>();
if name_args.is_empty() {
return Err(UUsageError::new(1, "missing operand".to_string()));
return Err(UUsageError::new(
1,
get_message("basename-error-missing-operand"),
));
}
let multiple_paths =
matches.get_one::<String>(options::SUFFIX).is_some() || matches.get_flag(options::MULTIPLE);
Expand All @@ -55,7 +59,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
_ => {
return Err(UUsageError::new(
1,
format!("extra operand {}", name_args[2].quote()),
get_message_with_args(
"basename-error-extra-operand",
HashMap::from([("operand".to_string(), name_args[2].quote().to_string())]),
),
));
}
}
Expand All @@ -82,7 +89,7 @@ pub fn uu_app() -> Command {
Arg::new(options::MULTIPLE)
.short('a')
.long(options::MULTIPLE)
.help("support multiple arguments and treat each as a NAME")
.help(get_message("basename-help-multiple"))
.action(ArgAction::SetTrue)
.overrides_with(options::MULTIPLE),
)
Expand All @@ -98,14 +105,14 @@ pub fn uu_app() -> Command {
.short('s')
.long(options::SUFFIX)
.value_name("SUFFIX")
.help("remove a trailing SUFFIX; implies -a")
.help(get_message("basename-help-suffix"))
.overrides_with(options::SUFFIX),
)
.arg(
Arg::new(options::ZERO)
.short('z')
.long(options::ZERO)
.help("end each output line with NUL, not newline")
.help(get_message("basename-help-zero"))
.action(ArgAction::SetTrue)
.overrides_with(options::ZERO),
)
Expand Down
Loading