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
18 changes: 18 additions & 0 deletions src/uu/dircolors/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,21 @@ dircolors-usage = dircolors [OPTION]... [FILE]
dircolors-after-help = If FILE is specified, read it to determine which colors to use for which
file types and extensions. Otherwise, a precompiled database is used.
For details on the format of these files, run 'dircolors --print-database'

# Help messages
dircolors-help-bourne-shell = output Bourne shell code to set LS_COLORS
dircolors-help-c-shell = output C shell code to set LS_COLORS
dircolors-help-print-database = print the byte counts
dircolors-help-print-ls-colors = output fully escaped colors for display

# Error messages
dircolors-error-shell-and-output-exclusive = the options to output non shell syntax,
and to select a shell syntax are mutually exclusive
dircolors-error-print-database-and-ls-colors-exclusive = options --print-database and --print-ls-colors are mutually exclusive
dircolors-error-extra-operand-print-database = extra operand { $operand }
file operands cannot be combined with --print-database (-p)
dircolors-error-no-shell-environment = no SHELL environment variable, and no shell type option given
dircolors-error-extra-operand = extra operand { $operand }
dircolors-error-expected-file-got-directory = expected file, got directory { $path }
dircolors-error-invalid-line-missing-token = { $file }:{ $line }: invalid line; missing second token
dircolors-error-unrecognized-keyword = unrecognized keyword { $keyword }
23 changes: 23 additions & 0 deletions src/uu/dircolors/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dircolors-about = Afficher les commandes pour définir la variable d'environnement LS_COLORS.
dircolors-usage = dircolors [OPTION]... [FICHIER]
dircolors-after-help = Si FICHIER est spécifié, le lire pour déterminer quelles couleurs utiliser pour quels
types de fichiers et extensions. Sinon, une base de données précompilée est utilisée.
Pour les détails sur le format de ces fichiers, exécutez 'dircolors --print-database'

# Messages d'aide
dircolors-help-bourne-shell = afficher le code Bourne shell pour définir LS_COLORS
dircolors-help-c-shell = afficher le code C shell pour définir LS_COLORS
dircolors-help-print-database = afficher la base de données de configuration
dircolors-help-print-ls-colors = afficher les couleurs entièrement échappées pour l'affichage

# Messages d'erreur
dircolors-error-shell-and-output-exclusive = les options pour afficher une syntaxe non-shell
et pour sélectionner une syntaxe shell sont mutuellement exclusives
dircolors-error-print-database-and-ls-colors-exclusive = les options --print-database et --print-ls-colors sont mutuellement exclusives
dircolors-error-extra-operand-print-database = opérande supplémentaire { $operand }
les opérandes de fichier ne peuvent pas être combinées avec --print-database (-p)
dircolors-error-no-shell-environment = aucune variable d'environnement SHELL, et aucune option de type de shell donnée
dircolors-error-extra-operand = opérande supplémentaire { $operand }
dircolors-error-expected-file-got-directory = fichier attendu, répertoire obtenu { $path }
dircolors-error-invalid-line-missing-token = { $file }:{ $line } : ligne invalide ; jeton manquant
dircolors-error-unrecognized-keyword = mot-clé non reconnu { $keyword }
50 changes: 30 additions & 20 deletions src/uu/dircolors/src/dircolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// spell-checker:ignore (ToDO) clrtoeol dircolors eightbit endcode fnmatch leftcode multihardlink rightcode setenv sgid suid colorterm disp

use std::borrow::Borrow;
use std::collections::HashMap;
use std::env;
use std::fmt::Write as _;
use std::fs::File;
Expand All @@ -16,7 +17,7 @@
use uucore::colors::{FILE_ATTRIBUTE_CODES, FILE_COLORS, FILE_TYPES, TERMS};
use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError, UUsageError};
use uucore::locale::get_message;
use uucore::locale::{get_message, get_message_with_args};
use uucore::{format_usage, parser::parse_glob};

mod options {
Expand Down Expand Up @@ -132,26 +133,24 @@
{
return Err(UUsageError::new(
1,
"the options to output non shell syntax,\n\
and to select a shell syntax are mutually exclusive",
get_message("dircolors-error-shell-and-output-exclusive"),
));
}

if matches.get_flag(options::PRINT_DATABASE) && matches.get_flag(options::PRINT_LS_COLORS) {
return Err(UUsageError::new(
1,
"options --print-database and --print-ls-colors are mutually exclusive",
get_message("dircolors-error-print-database-and-ls-colors-exclusive"),
));
}

if matches.get_flag(options::PRINT_DATABASE) {
if !files.is_empty() {
return Err(UUsageError::new(
1,
format!(
"extra operand {}\nfile operands cannot be combined with \
--print-database (-p)",
files[0].quote()
get_message_with_args(
"dircolors-error-extra-operand-print-database",
HashMap::from([("operand".to_string(), files[0].quote().to_string())]),

Check warning on line 153 in src/uu/dircolors/src/dircolors.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/dircolors/src/dircolors.rs#L151-L153

Added lines #L151 - L153 were not covered by tests
),
));
}
Expand All @@ -175,7 +174,7 @@
OutputFmt::Unknown => {
return Err(USimpleError::new(
1,
"no SHELL environment variable, and no shell type option given",
get_message("dircolors-error-no-shell-environment"),
));
}
fmt => out_format = fmt,
Expand All @@ -201,7 +200,10 @@
} else if files.len() > 1 {
return Err(UUsageError::new(
1,
format!("extra operand {}", files[1].quote()),
get_message_with_args(
"dircolors-error-extra-operand",
HashMap::from([("operand".to_string(), files[1].quote().to_string())]),
),
));
} else if files[0].eq("-") {
let fin = BufReader::new(std::io::stdin());
Expand All @@ -212,7 +214,10 @@
if path.is_dir() {
return Err(USimpleError::new(
2,
format!("expected file, got directory {}", path.quote()),
get_message_with_args(
"dircolors-error-expected-file-got-directory",
HashMap::from([("path".to_string(), path.quote().to_string())]),
),
));
}
match File::open(path) {
Expand Down Expand Up @@ -253,7 +258,7 @@
.short('b')
.visible_alias("bourne-shell")
.overrides_with(options::C_SHELL)
.help("output Bourne shell code to set LS_COLORS")
.help(get_message("dircolors-help-bourne-shell"))
.action(ArgAction::SetTrue),
)
.arg(
Expand All @@ -262,20 +267,20 @@
.short('c')
.visible_alias("c-shell")
.overrides_with(options::BOURNE_SHELL)
.help("output C shell code to set LS_COLORS")
.help(get_message("dircolors-help-c-shell"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::PRINT_DATABASE)
.long("print-database")
.short('p')
.help("print the byte counts")
.help(get_message("dircolors-help-print-database"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::PRINT_LS_COLORS)
.long("print-ls-colors")
.help("output fully escaped colors for display")
.help(get_message("dircolors-help-print-ls-colors"))
.action(ArgAction::SetTrue),
)
.arg(
Expand Down Expand Up @@ -375,10 +380,12 @@

let (key, val) = line.split_two();
if val.is_empty() {
return Err(format!(
// The double space is what GNU is doing
"{}:{num}: invalid line; missing second token",
fp.maybe_quote(),
return Err(get_message_with_args(
"dircolors-error-invalid-line-missing-token",
HashMap::from([
("file".to_string(), fp.maybe_quote().to_string()),
("line".to_string(), num.to_string()),
]),

Check warning on line 388 in src/uu/dircolors/src/dircolors.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/dircolors/src/dircolors.rs#L383-L388

Added lines #L383 - L388 were not covered by tests
));
}

Expand Down Expand Up @@ -461,7 +468,10 @@
result.push_str(&disp);
Ok(())
} else {
Err(format!("unrecognized keyword {key}"))
Err(get_message_with_args(
"dircolors-error-unrecognized-keyword",
HashMap::from([("keyword".to_string(), key.to_string())]),
))

Check warning on line 474 in src/uu/dircolors/src/dircolors.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/dircolors/src/dircolors.rs#L471-L474

Added lines #L471 - L474 were not covered by tests
}
}
}
Expand Down
Loading