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
14 changes: 14 additions & 0 deletions src/uu/readlink/locales/en-US.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
readlink-about = Print value of a symbolic link or canonical file name.
readlink-usage = readlink [OPTION]... [FILE]...

# Help messages
readlink-help-canonicalize = canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist
readlink-help-canonicalize-existing = canonicalize by following every symlink in every component of the given name recursively, all components must exist
readlink-help-canonicalize-missing = canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence
readlink-help-no-newline = do not output the trailing delimiter
readlink-help-quiet = suppress most error messages
readlink-help-silent = suppress most error messages
readlink-help-verbose = report error message
readlink-help-zero = separate output with NUL rather than newline

# Error messages
readlink-error-missing-operand = missing operand
readlink-error-ignoring-no-newline = ignoring --no-newline with multiple arguments
16 changes: 16 additions & 0 deletions src/uu/readlink/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
readlink-about = Afficher la valeur d'un lien symbolique ou le nom de fichier canonique.
readlink-usage = readlink [OPTION]... [FICHIER]...

# Messages d'aide
readlink-help-canonicalize = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive ; tous les composants sauf le dernier doivent exister
readlink-help-canonicalize-existing = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive, tous les composants doivent exister
readlink-help-canonicalize-missing = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive, sans exigences sur l'existence des composants
readlink-help-no-newline = ne pas afficher le délimiteur final
readlink-help-quiet = supprimer la plupart des messages d'erreur
readlink-help-silent = supprimer la plupart des messages d'erreur
readlink-help-verbose = signaler les messages d'erreur
readlink-help-zero = séparer la sortie avec NUL plutôt qu'une nouvelle ligne

# Messages d'erreur
readlink-error-missing-operand = opérande manquant
readlink-error-ignoring-no-newline = ignorer --no-newline avec plusieurs arguments
37 changes: 17 additions & 20 deletions src/uu/readlink/src/readlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
use uucore::line_ending::LineEnding;
use uucore::locale::get_message;
use uucore::{format_usage, show_error};

use uucore::locale::get_message;
const OPT_CANONICALIZE: &str = "canonicalize";
const OPT_CANONICALIZE_MISSING: &str = "canonicalize-missing";
const OPT_CANONICALIZE_EXISTING: &str = "canonicalize-existing";
Expand Down Expand Up @@ -57,14 +57,19 @@
.get_many::<String>(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default();

if files.is_empty() {
return Err(UUsageError::new(1, "missing operand"));
return Err(UUsageError::new(
1,
get_message("readlink-error-missing-operand"),
));

Check warning on line 65 in src/uu/readlink/src/readlink.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/readlink/src/readlink.rs#L62-L65

Added lines #L62 - L65 were not covered by tests
}

if no_trailing_delimiter && files.len() > 1 && !silent {
show_error!("ignoring --no-newline with multiple arguments");
show_error!("{}", get_message("readlink-error-ignoring-no-newline"));
no_trailing_delimiter = false;
}

let line_ending = if no_trailing_delimiter {
None
} else {
Expand All @@ -78,6 +83,7 @@
} else {
canonicalize(&p, can_mode, res_mode)
};

match path_result {
Ok(path) => {
show(&path, line_ending).map_err_context(String::new)?;
Expand Down Expand Up @@ -108,65 +114,56 @@
Arg::new(OPT_CANONICALIZE)
.short('f')
.long(OPT_CANONICALIZE)
.help(
"canonicalize by following every symlink in every component of the \
given name recursively; all but the last component must exist",
)
.help(get_message("readlink-help-canonicalize"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_CANONICALIZE_EXISTING)
.short('e')
.long("canonicalize-existing")
.help(
"canonicalize by following every symlink in every component of the \
given name recursively, all components must exist",
)
.help(get_message("readlink-help-canonicalize-existing"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_CANONICALIZE_MISSING)
.short('m')
.long(OPT_CANONICALIZE_MISSING)
.help(
"canonicalize by following every symlink in every component of the \
given name recursively, without requirements on components existence",
)
.help(get_message("readlink-help-canonicalize-missing"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_NO_NEWLINE)
.short('n')
.long(OPT_NO_NEWLINE)
.help("do not output the trailing delimiter")
.help(get_message("readlink-help-no-newline"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_QUIET)
.short('q')
.long(OPT_QUIET)
.help("suppress most error messages")
.help(get_message("readlink-help-quiet"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_SILENT)
.short('s')
.long(OPT_SILENT)
.help("suppress most error messages")
.help(get_message("readlink-help-silent"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_VERBOSE)
.short('v')
.long(OPT_VERBOSE)
.help("report error message")
.help(get_message("readlink-help-verbose"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_ZERO)
.short('z')
.long(OPT_ZERO)
.help("separate output with NUL rather than newline")
.help(get_message("readlink-help-zero"))
.action(ArgAction::SetTrue),
)
.arg(
Expand Down
Loading