mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
l10n: port pr for translation + add french
This commit is contained in:
parent
05eb7ee374
commit
6b2ccde2bc
3 changed files with 283 additions and 154 deletions
|
@ -1,19 +1,95 @@
|
||||||
pr-about = Write content of given file or standard input to standard output with pagination filter
|
pr-about = paginate or columnate FILE(s) for printing
|
||||||
|
pr-after-help =
|
||||||
|
If no FILE(s) are given, or if FILE is -, read standard input.
|
||||||
|
|
||||||
|
When creating multicolumn output, columns will be of equal width. When using
|
||||||
|
the '-s' option to separate columns, the default separator is a single tab
|
||||||
|
character. When using the '-S' option to separate columns, the default separator
|
||||||
|
is a single space character.
|
||||||
pr-usage = pr [OPTION]... [FILE]...
|
pr-usage = pr [OPTION]... [FILE]...
|
||||||
pr-after-help = +PAGE Begin output at page number page of the formatted input.
|
|
||||||
-COLUMN Produce multi-column output. See --column
|
|
||||||
|
|
||||||
The pr utility is a printing and pagination filter for text files.
|
# Help messages
|
||||||
When multiple input files are specified, each is read, formatted, and written to standard output.
|
pr-help-pages = Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]
|
||||||
By default, the input is separated into 66-line pages, each with
|
pr-help-header =
|
||||||
|
Use the string header to replace the file name
|
||||||
|
in the header line.
|
||||||
|
pr-help-double-space =
|
||||||
|
Produce output that is double spaced. An extra <newline>
|
||||||
|
character is output following every <newline> found in the input.
|
||||||
|
pr-help-number-lines =
|
||||||
|
Provide width digit line numbering. The default for width,
|
||||||
|
if not specified, is 5. The number occupies the first width column
|
||||||
|
positions of each text column or each line of -m output. If char
|
||||||
|
(any non-digit character) is given, it is appended to the line number
|
||||||
|
to separate it from whatever follows. The default for char is a <tab>.
|
||||||
|
Line numbers longer than width columns are truncated.
|
||||||
|
pr-help-first-line-number = start counting with NUMBER at 1st line of first page printed
|
||||||
|
pr-help-omit-header =
|
||||||
|
Write neither the five-line identifying header nor the five-line
|
||||||
|
trailer usually supplied for each page. Quit writing after the last line
|
||||||
|
of each file without spacing to the end of the page.
|
||||||
|
pr-help-page-length =
|
||||||
|
Override the 66-line default (default number of lines of text 56,
|
||||||
|
and with -F 63) and reset the page length to lines. If lines is not
|
||||||
|
greater than the sum of both the header and trailer depths (in lines),
|
||||||
|
the pr utility shall suppress both the header and trailer, as if the -t
|
||||||
|
option were in effect.
|
||||||
|
pr-help-no-file-warnings = omit warning when a file cannot be opened
|
||||||
|
pr-help-form-feed =
|
||||||
|
Use a <form-feed> for new pages, instead of the default behavior that
|
||||||
|
uses a sequence of <newline>s.
|
||||||
|
pr-help-column-width =
|
||||||
|
Set the width of the line to width column positions for multiple
|
||||||
|
text-column output only. If the -w option is not specified and the -s option
|
||||||
|
is not specified, the default width shall be 72. If the -w option is not specified
|
||||||
|
and the -s option is specified, the default width shall be 512.
|
||||||
|
pr-help-page-width =
|
||||||
|
set page width to PAGE_WIDTH (72) characters always,
|
||||||
|
truncate lines, except -J option is set, no interference
|
||||||
|
with -S or -s
|
||||||
|
pr-help-across =
|
||||||
|
Modify the effect of the - column option so that the columns are filled
|
||||||
|
across the page in a round-robin order (for example, when column is 2, the
|
||||||
|
first input line heads column 1, the second heads column 2, the third is the
|
||||||
|
second line in column 1, and so on).
|
||||||
|
pr-help-column =
|
||||||
|
Produce multi-column output that is arranged in column columns
|
||||||
|
(the default shall be 1) and is written down each column in the order in which
|
||||||
|
the text is received from the input file. This option should not be used with -m.
|
||||||
|
The options -e and -i shall be assumed for multiple text-column output. Whether
|
||||||
|
or not text columns are produced with identical vertical lengths is unspecified,
|
||||||
|
but a text column shall never exceed the length of the page (see the -l option).
|
||||||
|
When used with -t, use the minimum number of lines to write the output.
|
||||||
|
pr-help-column-char-separator =
|
||||||
|
Separate text columns by the single character char instead of by the
|
||||||
|
appropriate number of <space>s (default for char is the <tab> character).
|
||||||
|
pr-help-column-string-separator =
|
||||||
|
separate columns by STRING,
|
||||||
|
without -S: Default separator <TAB> with -J and <space>
|
||||||
|
otherwise (same as -S\" \"), no effect on column options
|
||||||
|
pr-help-merge =
|
||||||
|
Merge files. Standard output shall be formatted so the pr utility
|
||||||
|
writes one line from each file specified by a file operand, side by side
|
||||||
|
into text columns of equal fixed widths, in terms of the number of column
|
||||||
|
positions. Implementations shall support merging of at least nine file operands.
|
||||||
|
pr-help-indent =
|
||||||
|
Each line of output shall be preceded by offset <space>s. If the -o
|
||||||
|
option is not specified, the default offset shall be zero. The space taken is
|
||||||
|
in addition to the output line width (see the -w option below).
|
||||||
|
pr-help-join-lines =
|
||||||
|
merge full lines, turns off -W line truncation, no column
|
||||||
|
alignment, --sep-string[=STRING] sets separators
|
||||||
|
pr-help-help = Print help information
|
||||||
|
|
||||||
- A 5-line header with the page number, date, time, and the pathname of the file.
|
# Page header text
|
||||||
- A 5-line trailer consisting of blank lines.
|
pr-page = Page
|
||||||
|
|
||||||
If standard output is associated with a terminal, diagnostic messages are suppressed until the pr
|
# Error messages
|
||||||
utility has completed processing.
|
pr-error-reading-input = pr: Reading from input {$file} gave error
|
||||||
|
pr-error-unknown-filetype = pr: {$file}: unknown filetype
|
||||||
When multiple column output is specified, text columns are of equal width.
|
pr-error-is-directory = pr: {$file}: Is a directory
|
||||||
By default, text columns are separated by at least one <blank>.
|
pr-error-socket-not-supported = pr: cannot open {$file}, Operation not supported on socket
|
||||||
Input lines that do not fit into a text column are truncated.
|
pr-error-no-such-file = pr: cannot open {$file}, No such file or directory
|
||||||
Lines are not truncated under single column output.
|
pr-error-column-merge-conflict = cannot specify number of columns when printing in parallel
|
||||||
|
pr-error-across-merge-conflict = cannot specify both printing across and printing in parallel
|
||||||
|
pr-error-invalid-pages-range = invalid --pages argument '{$start}:{$end}'
|
||||||
|
|
97
src/uu/pr/locales/fr-FR.ftl
Normal file
97
src/uu/pr/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
pr-about = paginer ou présenter en colonnes le(s) FICHIER(s) pour l'impression
|
||||||
|
pr-after-help =
|
||||||
|
Si aucun FICHIER n'est donné, ou si FICHIER est -, lire l'entrée standard.
|
||||||
|
|
||||||
|
Lors de la création d'une sortie multi-colonnes, les colonnes auront une largeur égale.
|
||||||
|
Lors de l'utilisation de l'option '-s' pour séparer les colonnes, le séparateur par défaut
|
||||||
|
est un caractère de tabulation unique. Lors de l'utilisation de l'option '-S' pour séparer
|
||||||
|
les colonnes, le séparateur par défaut est un caractère d'espace unique.
|
||||||
|
pr-usage = pr [OPTION]... [FICHIER]...
|
||||||
|
|
||||||
|
# Messages d'aide
|
||||||
|
pr-help-pages = Commencer et arrêter l'impression à la page PREMIÈRE_PAGE[:DERNIÈRE_PAGE]
|
||||||
|
pr-help-header =
|
||||||
|
Utiliser la chaîne d'en-tête pour remplacer le nom de fichier
|
||||||
|
dans la ligne d'en-tête.
|
||||||
|
pr-help-double-space =
|
||||||
|
Produire une sortie avec double espacement. Un caractère <saut de ligne>
|
||||||
|
supplémentaire est affiché après chaque <saut de ligne> trouvé dans l'entrée.
|
||||||
|
pr-help-number-lines =
|
||||||
|
Fournir une numérotation de ligne avec largeur de chiffres. La valeur par défaut
|
||||||
|
pour la largeur, si non spécifiée, est 5. Le numéro occupe les premières
|
||||||
|
largeur positions de colonne de chaque colonne de texte ou de chaque ligne
|
||||||
|
de sortie -m. Si char (tout caractère non numérique) est donné, il est
|
||||||
|
ajouté au numéro de ligne pour le séparer de ce qui suit. La valeur par
|
||||||
|
défaut pour char est une <tabulation>. Les numéros de ligne plus longs
|
||||||
|
que largeur colonnes sont tronqués.
|
||||||
|
pr-help-first-line-number = commencer le comptage avec NUMÉRO à la 1ère ligne de la première page imprimée
|
||||||
|
pr-help-omit-header =
|
||||||
|
N'écrire ni l'en-tête d'identification de cinq lignes ni le pied de page
|
||||||
|
de cinq lignes habituellement fournis pour chaque page. Arrêter l'écriture
|
||||||
|
après la dernière ligne de chaque fichier sans espacement jusqu'à la fin de la page.
|
||||||
|
pr-help-page-length =
|
||||||
|
Remplacer la valeur par défaut de 66 lignes (nombre par défaut de lignes de texte 56,
|
||||||
|
et avec -F 63) et réinitialiser la longueur de page à lignes. Si lignes n'est pas
|
||||||
|
supérieur à la somme des profondeurs de l'en-tête et du pied de page (en lignes),
|
||||||
|
l'utilitaire pr supprimera à la fois l'en-tête et le pied de page, comme si l'option -t
|
||||||
|
était en vigueur.
|
||||||
|
pr-help-no-file-warnings = omettre l'avertissement lorsqu'un fichier ne peut pas être ouvert
|
||||||
|
pr-help-form-feed =
|
||||||
|
Utiliser un <saut de page> pour les nouvelles pages, au lieu du comportement par défaut
|
||||||
|
qui utilise une séquence de <sauts de ligne>.
|
||||||
|
pr-help-column-width =
|
||||||
|
Définir la largeur de la ligne à largeur positions de colonne pour la sortie
|
||||||
|
multi-colonnes de texte seulement. Si l'option -w n'est pas spécifiée et
|
||||||
|
l'option -s n'est pas spécifiée, la largeur par défaut sera 72. Si l'option -w
|
||||||
|
n'est pas spécifiée et l'option -s est spécifiée, la largeur par défaut sera 512.
|
||||||
|
pr-help-page-width =
|
||||||
|
définir la largeur de page à PAGE_WIDTH (72) caractères toujours,
|
||||||
|
tronquer les lignes, sauf si l'option -J est définie, aucune interférence
|
||||||
|
avec -S ou -s
|
||||||
|
pr-help-across =
|
||||||
|
Modifier l'effet de l'option - colonne pour que les colonnes soient remplies
|
||||||
|
à travers la page dans un ordre round-robin (par exemple, quand colonne est 2,
|
||||||
|
la première ligne d'entrée va en tête de colonne 1, la seconde va en tête de colonne 2,
|
||||||
|
la troisième est la seconde ligne en colonne 1, et ainsi de suite).
|
||||||
|
pr-help-column =
|
||||||
|
Produire une sortie multi-colonnes qui est arrangée en colonnes colonnes
|
||||||
|
(la valeur par défaut sera 1) et est écrite dans chaque colonne dans l'ordre
|
||||||
|
dans lequel le texte est reçu du fichier d'entrée. Cette option ne doit pas être
|
||||||
|
utilisée avec -m. Les options -e et -i seront assumées pour la sortie multi-colonnes
|
||||||
|
de texte. Que les colonnes de texte soient produites avec des longueurs verticales
|
||||||
|
identiques ou non n'est pas spécifié, mais une colonne de texte ne doit jamais
|
||||||
|
dépasser la longueur de la page (voir l'option -l). Lorsqu'utilisée avec -t,
|
||||||
|
utiliser le nombre minimum de lignes pour écrire la sortie.
|
||||||
|
pr-help-column-char-separator =
|
||||||
|
Séparer les colonnes de texte par le caractère unique char au lieu du nombre
|
||||||
|
approprié d'<espaces> (par défaut pour char est le caractère de <tabulation>).
|
||||||
|
pr-help-column-string-separator =
|
||||||
|
séparer les colonnes par CHAÎNE,
|
||||||
|
sans -S : Séparateur par défaut <TAB> avec -J et <espace>
|
||||||
|
sinon (même que -S\" \"), aucun effet sur les options de colonne
|
||||||
|
pr-help-merge =
|
||||||
|
Fusionner les fichiers. La sortie standard sera formatée pour que l'utilitaire pr
|
||||||
|
écrive une ligne de chaque fichier spécifié par un opérande de fichier, côte à côte
|
||||||
|
dans des colonnes de texte de largeurs fixes égales, en termes du nombre de positions
|
||||||
|
de colonne. Les implémentations doivent supporter la fusion d'au moins neuf opérandes de fichier.
|
||||||
|
pr-help-indent =
|
||||||
|
Chaque ligne de sortie sera précédée par décalage <espaces>. Si l'option -o
|
||||||
|
n'est pas spécifiée, le décalage par défaut sera zéro. L'espace pris est
|
||||||
|
en plus de la largeur de ligne de sortie (voir l'option -w ci-dessous).
|
||||||
|
pr-help-join-lines =
|
||||||
|
fusionner les lignes complètes, désactive la troncature de ligne -W, aucun
|
||||||
|
alignement de colonne, --sep-string[=CHAÎNE] définit les séparateurs
|
||||||
|
pr-help-help = Afficher les informations d'aide
|
||||||
|
|
||||||
|
# Texte d'en-tête de page
|
||||||
|
pr-page = Page
|
||||||
|
|
||||||
|
# Messages d'erreur
|
||||||
|
pr-error-reading-input = pr : La lecture depuis l'entrée {$file} a donné une erreur
|
||||||
|
pr-error-unknown-filetype = pr : {$file} : type de fichier inconnu
|
||||||
|
pr-error-is-directory = pr : {$file} : Est un répertoire
|
||||||
|
pr-error-socket-not-supported = pr : impossible d'ouvrir {$file}, Opération non supportée sur socket
|
||||||
|
pr-error-no-such-file = pr : impossible d'ouvrir {$file}, Aucun fichier ou répertoire de ce type
|
||||||
|
pr-error-column-merge-conflict = impossible de spécifier le nombre de colonnes lors de l'impression en parallèle
|
||||||
|
pr-error-across-merge-conflict = impossible de spécifier à la fois l'impression transversale et l'impression en parallèle
|
||||||
|
pr-error-invalid-pages-range = argument --pages invalide '{$start}:{$end}'
|
|
@ -20,7 +20,8 @@ use uucore::display::Quotable;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
|
|
||||||
use uucore::locale::get_message;
|
use std::collections::HashMap;
|
||||||
|
use uucore::locale::{get_message, get_message_with_args};
|
||||||
const TAB: char = '\t';
|
const TAB: char = '\t';
|
||||||
const LINES_PER_PAGE: usize = 66;
|
const LINES_PER_PAGE: usize = 66;
|
||||||
const LINES_PER_PAGE_FOR_FORM_FEED: usize = 63;
|
const LINES_PER_PAGE_FOR_FORM_FEED: usize = 63;
|
||||||
|
@ -127,25 +128,31 @@ impl Default for FileLine {
|
||||||
|
|
||||||
impl From<std::io::Error> for PrError {
|
impl From<std::io::Error> for PrError {
|
||||||
fn from(err: std::io::Error) -> Self {
|
fn from(err: std::io::Error) -> Self {
|
||||||
Self::EncounteredErrors(err.to_string())
|
Self::EncounteredErrors {
|
||||||
|
msg: err.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
enum PrError {
|
enum PrError {
|
||||||
#[error("pr: Reading from input {1} gave error")]
|
#[error("{}", get_message_with_args("pr-error-reading-input", HashMap::from([("file".to_string(), file.clone())])))]
|
||||||
Input(std::io::Error, String),
|
Input {
|
||||||
#[error("pr: {0}: unknown filetype")]
|
#[source]
|
||||||
UnknownFiletype(String),
|
source: std::io::Error,
|
||||||
#[error("pr: {0}")]
|
file: String,
|
||||||
EncounteredErrors(String),
|
},
|
||||||
#[error("pr: {0}: Is a directory")]
|
#[error("{}", get_message_with_args("pr-error-unknown-filetype", HashMap::from([("file".to_string(), file.clone())])))]
|
||||||
IsDirectory(String),
|
UnknownFiletype { file: String },
|
||||||
|
#[error("pr: {msg}")]
|
||||||
|
EncounteredErrors { msg: String },
|
||||||
|
#[error("{}", get_message_with_args("pr-error-is-directory", HashMap::from([("file".to_string(), file.clone())])))]
|
||||||
|
IsDirectory { file: String },
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[error("pr: cannot open {0}, Operation not supported on socket")]
|
#[error("{}", get_message_with_args("pr-error-socket-not-supported", HashMap::from([("file".to_string(), file.clone())])))]
|
||||||
IsSocket(String),
|
IsSocket { file: String },
|
||||||
#[error("pr: cannot open {0}, No such file or directory")]
|
#[error("{}", get_message_with_args("pr-error-no-such-file", HashMap::from([("file".to_string(), file.clone())])))]
|
||||||
NotExists(String),
|
NotExists { file: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> Command {
|
pub fn uu_app() -> Command {
|
||||||
|
@ -160,41 +167,28 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::PAGES)
|
Arg::new(options::PAGES)
|
||||||
.long(options::PAGES)
|
.long(options::PAGES)
|
||||||
.help("Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]")
|
.help(get_message("pr-help-pages"))
|
||||||
.value_name("FIRST_PAGE[:LAST_PAGE]"),
|
.value_name("FIRST_PAGE[:LAST_PAGE]"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::HEADER)
|
Arg::new(options::HEADER)
|
||||||
.short('h')
|
.short('h')
|
||||||
.long(options::HEADER)
|
.long(options::HEADER)
|
||||||
.help(
|
.help(get_message("pr-help-header"))
|
||||||
"Use the string header to replace the file name \
|
|
||||||
in the header line.",
|
|
||||||
)
|
|
||||||
.value_name("STRING"),
|
.value_name("STRING"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::DOUBLE_SPACE)
|
Arg::new(options::DOUBLE_SPACE)
|
||||||
.short('d')
|
.short('d')
|
||||||
.long(options::DOUBLE_SPACE)
|
.long(options::DOUBLE_SPACE)
|
||||||
.help(
|
.help(get_message("pr-help-double-space"))
|
||||||
"Produce output that is double spaced. An extra <newline> \
|
|
||||||
character is output following every <newline> found in the input.",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::NUMBER_LINES)
|
Arg::new(options::NUMBER_LINES)
|
||||||
.short('n')
|
.short('n')
|
||||||
.long(options::NUMBER_LINES)
|
.long(options::NUMBER_LINES)
|
||||||
.help(
|
.help(get_message("pr-help-number-lines"))
|
||||||
"Provide width digit line numbering. The default for width, \
|
|
||||||
if not specified, is 5. The number occupies the first width column \
|
|
||||||
positions of each text column or each line of -m output. If char \
|
|
||||||
(any non-digit character) is given, it is appended to the line number \
|
|
||||||
to separate it from whatever follows. The default for char is a <tab>. \
|
|
||||||
Line numbers longer than width columns are truncated.",
|
|
||||||
)
|
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true)
|
||||||
.value_name("[char][width]"),
|
.value_name("[char][width]"),
|
||||||
)
|
)
|
||||||
|
@ -202,38 +196,28 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::FIRST_LINE_NUMBER)
|
Arg::new(options::FIRST_LINE_NUMBER)
|
||||||
.short('N')
|
.short('N')
|
||||||
.long(options::FIRST_LINE_NUMBER)
|
.long(options::FIRST_LINE_NUMBER)
|
||||||
.help("start counting with NUMBER at 1st line of first page printed")
|
.help(get_message("pr-help-first-line-number"))
|
||||||
.value_name("NUMBER"),
|
.value_name("NUMBER"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::OMIT_HEADER)
|
Arg::new(options::OMIT_HEADER)
|
||||||
.short('t')
|
.short('t')
|
||||||
.long(options::OMIT_HEADER)
|
.long(options::OMIT_HEADER)
|
||||||
.help(
|
.help(get_message("pr-help-omit-header"))
|
||||||
"Write neither the five-line identifying header nor the five-line \
|
|
||||||
trailer usually supplied for each page. Quit writing after the last line \
|
|
||||||
of each file without spacing to the end of the page.",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::PAGE_LENGTH)
|
Arg::new(options::PAGE_LENGTH)
|
||||||
.short('l')
|
.short('l')
|
||||||
.long(options::PAGE_LENGTH)
|
.long(options::PAGE_LENGTH)
|
||||||
.help(
|
.help(get_message("pr-help-page-length"))
|
||||||
"Override the 66-line default (default number of lines of text 56, \
|
|
||||||
and with -F 63) and reset the page length to lines. If lines is not \
|
|
||||||
greater than the sum of both the header and trailer depths (in lines), \
|
|
||||||
the pr utility shall suppress both the header and trailer, as if the -t \
|
|
||||||
option were in effect. ",
|
|
||||||
)
|
|
||||||
.value_name("PAGE_LENGTH"),
|
.value_name("PAGE_LENGTH"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::NO_FILE_WARNINGS)
|
Arg::new(options::NO_FILE_WARNINGS)
|
||||||
.short('r')
|
.short('r')
|
||||||
.long(options::NO_FILE_WARNINGS)
|
.long(options::NO_FILE_WARNINGS)
|
||||||
.help("omit warning when a file cannot be opened")
|
.help(get_message("pr-help-no-file-warnings"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -241,118 +225,74 @@ pub fn uu_app() -> Command {
|
||||||
.short('F')
|
.short('F')
|
||||||
.short_alias('f')
|
.short_alias('f')
|
||||||
.long(options::FORM_FEED)
|
.long(options::FORM_FEED)
|
||||||
.help(
|
.help(get_message("pr-help-form-feed"))
|
||||||
"Use a <form-feed> for new pages, instead of the default behavior that \
|
|
||||||
uses a sequence of <newline>s.",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::COLUMN_WIDTH)
|
Arg::new(options::COLUMN_WIDTH)
|
||||||
.short('w')
|
.short('w')
|
||||||
.long(options::COLUMN_WIDTH)
|
.long(options::COLUMN_WIDTH)
|
||||||
.help(
|
.help(get_message("pr-help-column-width"))
|
||||||
"Set the width of the line to width column positions for multiple \
|
|
||||||
text-column output only. If the -w option is not specified and the -s option \
|
|
||||||
is not specified, the default width shall be 72. If the -w option is not specified \
|
|
||||||
and the -s option is specified, the default width shall be 512.",
|
|
||||||
)
|
|
||||||
.value_name("width"),
|
.value_name("width"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::PAGE_WIDTH)
|
Arg::new(options::PAGE_WIDTH)
|
||||||
.short('W')
|
.short('W')
|
||||||
.long(options::PAGE_WIDTH)
|
.long(options::PAGE_WIDTH)
|
||||||
.help(
|
.help(get_message("pr-help-page-width"))
|
||||||
"set page width to PAGE_WIDTH (72) characters always, \
|
|
||||||
truncate lines, except -J option is set, no interference \
|
|
||||||
with -S or -s",
|
|
||||||
)
|
|
||||||
.value_name("width"),
|
.value_name("width"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::ACROSS)
|
Arg::new(options::ACROSS)
|
||||||
.short('a')
|
.short('a')
|
||||||
.long(options::ACROSS)
|
.long(options::ACROSS)
|
||||||
.help(
|
.help(get_message("pr-help-across"))
|
||||||
"Modify the effect of the - column option so that the columns are filled \
|
|
||||||
across the page in a round-robin order (for example, when column is 2, the \
|
|
||||||
first input line heads column 1, the second heads column 2, the third is the \
|
|
||||||
second line in column 1, and so on).",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::COLUMN)
|
Arg::new(options::COLUMN)
|
||||||
.long(options::COLUMN)
|
.long(options::COLUMN)
|
||||||
.help(
|
.help(get_message("pr-help-column"))
|
||||||
"Produce multi-column output that is arranged in column columns \
|
|
||||||
(the default shall be 1) and is written down each column in the order in which \
|
|
||||||
the text is received from the input file. This option should not be used with -m. \
|
|
||||||
The options -e and -i shall be assumed for multiple text-column output. Whether \
|
|
||||||
or not text columns are produced with identical vertical lengths is unspecified, \
|
|
||||||
but a text column shall never exceed the length of the page (see the -l option). \
|
|
||||||
When used with -t, use the minimum number of lines to write the output.",
|
|
||||||
)
|
|
||||||
.value_name("column"),
|
.value_name("column"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::COLUMN_CHAR_SEPARATOR)
|
Arg::new(options::COLUMN_CHAR_SEPARATOR)
|
||||||
.short('s')
|
.short('s')
|
||||||
.long(options::COLUMN_CHAR_SEPARATOR)
|
.long(options::COLUMN_CHAR_SEPARATOR)
|
||||||
.help(
|
.help(get_message("pr-help-column-char-separator"))
|
||||||
"Separate text columns by the single character char instead of by the \
|
|
||||||
appropriate number of <space>s (default for char is the <tab> character).",
|
|
||||||
)
|
|
||||||
.value_name("char"),
|
.value_name("char"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::COLUMN_STRING_SEPARATOR)
|
Arg::new(options::COLUMN_STRING_SEPARATOR)
|
||||||
.short('S')
|
.short('S')
|
||||||
.long(options::COLUMN_STRING_SEPARATOR)
|
.long(options::COLUMN_STRING_SEPARATOR)
|
||||||
.help(
|
.help(get_message("pr-help-column-string-separator"))
|
||||||
"separate columns by STRING, \
|
|
||||||
without -S: Default separator <TAB> with -J and <space> \
|
|
||||||
otherwise (same as -S\" \"), no effect on column options",
|
|
||||||
)
|
|
||||||
.value_name("string"),
|
.value_name("string"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::MERGE)
|
Arg::new(options::MERGE)
|
||||||
.short('m')
|
.short('m')
|
||||||
.long(options::MERGE)
|
.long(options::MERGE)
|
||||||
.help(
|
.help(get_message("pr-help-merge"))
|
||||||
"Merge files. Standard output shall be formatted so the pr utility \
|
|
||||||
writes one line from each file specified by a file operand, side by side \
|
|
||||||
into text columns of equal fixed widths, in terms of the number of column \
|
|
||||||
positions. Implementations shall support merging of at least nine file operands.",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::INDENT)
|
Arg::new(options::INDENT)
|
||||||
.short('o')
|
.short('o')
|
||||||
.long(options::INDENT)
|
.long(options::INDENT)
|
||||||
.help(
|
.help(get_message("pr-help-indent"))
|
||||||
"Each line of output shall be preceded by offset <space>s. If the -o \
|
|
||||||
option is not specified, the default offset shall be zero. The space taken is \
|
|
||||||
in addition to the output line width (see the -w option below).",
|
|
||||||
)
|
|
||||||
.value_name("margin"),
|
.value_name("margin"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::JOIN_LINES)
|
Arg::new(options::JOIN_LINES)
|
||||||
.short('J')
|
.short('J')
|
||||||
.help(
|
.help(get_message("pr-help-join-lines"))
|
||||||
"merge full lines, turns off -W line truncation, no column \
|
|
||||||
alignment, --sep-string[=STRING] sets separators",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::HELP)
|
Arg::new(options::HELP)
|
||||||
.long(options::HELP)
|
.long(options::HELP)
|
||||||
.help("Print help information")
|
.help(get_message("pr-help-help"))
|
||||||
.action(ArgAction::Help),
|
.action(ArgAction::Help),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -452,8 +392,8 @@ fn parse_usize(matches: &ArgMatches, opt: &str) -> Option<Result<usize, PrError>
|
||||||
let from_parse_error_to_pr_error = |value_to_parse: (String, String)| {
|
let from_parse_error_to_pr_error = |value_to_parse: (String, String)| {
|
||||||
let i = value_to_parse.0;
|
let i = value_to_parse.0;
|
||||||
let option = value_to_parse.1;
|
let option = value_to_parse.1;
|
||||||
i.parse().map_err(|_e| {
|
i.parse().map_err(|_e| PrError::EncounteredErrors {
|
||||||
PrError::EncounteredErrors(format!("invalid {option} argument {}", i.quote()))
|
msg: format!("invalid {option} argument {}", i.quote()),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
matches
|
matches
|
||||||
|
@ -473,13 +413,15 @@ fn build_options(
|
||||||
let is_merge_mode = matches.get_flag(options::MERGE);
|
let is_merge_mode = matches.get_flag(options::MERGE);
|
||||||
|
|
||||||
if is_merge_mode && matches.contains_id(options::COLUMN) {
|
if is_merge_mode && matches.contains_id(options::COLUMN) {
|
||||||
let err_msg = String::from("cannot specify number of columns when printing in parallel");
|
return Err(PrError::EncounteredErrors {
|
||||||
return Err(PrError::EncounteredErrors(err_msg));
|
msg: get_message("pr-error-column-merge-conflict"),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_merge_mode && matches.get_flag(options::ACROSS) {
|
if is_merge_mode && matches.get_flag(options::ACROSS) {
|
||||||
let err_msg = String::from("cannot specify both printing across and printing in parallel");
|
return Err(PrError::EncounteredErrors {
|
||||||
return Err(PrError::EncounteredErrors(err_msg));
|
msg: get_message("pr-error-across-merge-conflict"),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let merge_files_print = if matches.get_flag(options::MERGE) {
|
let merge_files_print = if matches.get_flag(options::MERGE) {
|
||||||
|
@ -556,9 +498,11 @@ fn build_options(
|
||||||
let res = page_plus_re.captures(free_args).map(|i| {
|
let res = page_plus_re.captures(free_args).map(|i| {
|
||||||
let unparsed_num = i.get(1).unwrap().as_str().trim();
|
let unparsed_num = i.get(1).unwrap().as_str().trim();
|
||||||
let x: Vec<_> = unparsed_num.split(':').collect();
|
let x: Vec<_> = unparsed_num.split(':').collect();
|
||||||
x[0].to_string().parse::<usize>().map_err(|_e| {
|
x[0].to_string()
|
||||||
PrError::EncounteredErrors(format!("invalid {} argument {}", "+", unparsed_num.quote()))
|
.parse::<usize>()
|
||||||
})
|
.map_err(|_e| PrError::EncounteredErrors {
|
||||||
|
msg: format!("invalid {} argument {}", "+", unparsed_num.quote()),
|
||||||
|
})
|
||||||
});
|
});
|
||||||
let start_page_in_plus_option = match res {
|
let start_page_in_plus_option = match res {
|
||||||
Some(res) => res?,
|
Some(res) => res?,
|
||||||
|
@ -571,13 +515,11 @@ fn build_options(
|
||||||
.filter(|i| i.contains(':'))
|
.filter(|i| i.contains(':'))
|
||||||
.map(|unparsed_num| {
|
.map(|unparsed_num| {
|
||||||
let x: Vec<_> = unparsed_num.split(':').collect();
|
let x: Vec<_> = unparsed_num.split(':').collect();
|
||||||
x[1].to_string().parse::<usize>().map_err(|_e| {
|
x[1].to_string()
|
||||||
PrError::EncounteredErrors(format!(
|
.parse::<usize>()
|
||||||
"invalid {} argument {}",
|
.map_err(|_e| PrError::EncounteredErrors {
|
||||||
"+",
|
msg: format!("invalid {} argument {}", "+", unparsed_num.quote()),
|
||||||
unparsed_num.quote()
|
})
|
||||||
))
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
let end_page_in_plus_option = match res {
|
let end_page_in_plus_option = match res {
|
||||||
Some(res) => Some(res?),
|
Some(res) => Some(res?),
|
||||||
|
@ -586,11 +528,8 @@ fn build_options(
|
||||||
|
|
||||||
let invalid_pages_map = |i: String| {
|
let invalid_pages_map = |i: String| {
|
||||||
let unparsed_value = matches.get_one::<String>(options::PAGES).unwrap();
|
let unparsed_value = matches.get_one::<String>(options::PAGES).unwrap();
|
||||||
i.parse::<usize>().map_err(|_e| {
|
i.parse::<usize>().map_err(|_e| PrError::EncounteredErrors {
|
||||||
PrError::EncounteredErrors(format!(
|
msg: format!("invalid --pages argument {}", unparsed_value.quote()),
|
||||||
"invalid --pages argument {}",
|
|
||||||
unparsed_value.quote()
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -621,9 +560,15 @@ fn build_options(
|
||||||
|
|
||||||
if let Some(end_page) = end_page {
|
if let Some(end_page) = end_page {
|
||||||
if start_page > end_page {
|
if start_page > end_page {
|
||||||
return Err(PrError::EncounteredErrors(format!(
|
return Err(PrError::EncounteredErrors {
|
||||||
"invalid --pages argument '{start_page}:{end_page}'"
|
msg: get_message_with_args(
|
||||||
)));
|
"pr-error-invalid-pages-range",
|
||||||
|
HashMap::from([
|
||||||
|
("start".to_string(), start_page.to_string()),
|
||||||
|
("end".to_string(), end_page.to_string()),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,9 +631,11 @@ fn build_options(
|
||||||
|
|
||||||
let res = re_col.captures(free_args).map(|i| {
|
let res = re_col.captures(free_args).map(|i| {
|
||||||
let unparsed_num = i.get(1).unwrap().as_str().trim();
|
let unparsed_num = i.get(1).unwrap().as_str().trim();
|
||||||
unparsed_num.parse::<usize>().map_err(|_e| {
|
unparsed_num
|
||||||
PrError::EncounteredErrors(format!("invalid {} argument {}", "-", unparsed_num.quote()))
|
.parse::<usize>()
|
||||||
})
|
.map_err(|_e| PrError::EncounteredErrors {
|
||||||
|
msg: format!("invalid {} argument {}", "-", unparsed_num.quote()),
|
||||||
|
})
|
||||||
});
|
});
|
||||||
let start_column_option = match res {
|
let start_column_option = match res {
|
||||||
Some(res) => Some(res?),
|
Some(res) => Some(res?),
|
||||||
|
@ -770,21 +717,28 @@ fn open(path: &str) -> Result<Box<dyn Read>, PrError> {
|
||||||
let path_string = path.to_string();
|
let path_string = path.to_string();
|
||||||
match i.file_type() {
|
match i.file_type() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
ft if ft.is_block_device() => Err(PrError::UnknownFiletype(path_string)),
|
ft if ft.is_block_device() => Err(PrError::UnknownFiletype { file: path_string }),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
ft if ft.is_char_device() => Err(PrError::UnknownFiletype(path_string)),
|
ft if ft.is_char_device() => Err(PrError::UnknownFiletype { file: path_string }),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
ft if ft.is_fifo() => Err(PrError::UnknownFiletype(path_string)),
|
ft if ft.is_fifo() => Err(PrError::UnknownFiletype { file: path_string }),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
ft if ft.is_socket() => Err(PrError::IsSocket(path_string)),
|
ft if ft.is_socket() => Err(PrError::IsSocket { file: path_string }),
|
||||||
ft if ft.is_dir() => Err(PrError::IsDirectory(path_string)),
|
ft if ft.is_dir() => Err(PrError::IsDirectory { file: path_string }),
|
||||||
ft if ft.is_file() || ft.is_symlink() => Ok(Box::new(
|
ft if ft.is_file() || ft.is_symlink() => {
|
||||||
File::open(path).map_err(|e| PrError::Input(e, path.to_string()))?,
|
Ok(Box::new(File::open(path).map_err(|e| PrError::Input {
|
||||||
) as Box<dyn Read>),
|
source: e,
|
||||||
_ => Err(PrError::UnknownFiletype(path_string)),
|
file: path.to_string(),
|
||||||
|
})?) as Box<dyn Read>)
|
||||||
|
}
|
||||||
|
_ => Err(PrError::UnknownFiletype { file: path_string }),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|_| Err(PrError::NotExists(path.to_string())))
|
.unwrap_or_else(|_| {
|
||||||
|
Err(PrError::NotExists {
|
||||||
|
file: path.to_string(),
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn split_lines_if_form_feed(file_content: Result<String, std::io::Error>) -> Vec<FileLine> {
|
fn split_lines_if_form_feed(file_content: Result<String, std::io::Error>) -> Vec<FileLine> {
|
||||||
|
@ -1161,8 +1115,10 @@ fn get_formatted_line_number(opts: &OutputOptions, line_number: usize, index: us
|
||||||
fn header_content(options: &OutputOptions, page: usize) -> Vec<String> {
|
fn header_content(options: &OutputOptions, page: usize) -> Vec<String> {
|
||||||
if options.display_header_and_trailer {
|
if options.display_header_and_trailer {
|
||||||
let first_line = format!(
|
let first_line = format!(
|
||||||
"{} {} Page {page}",
|
"{} {} {} {page}",
|
||||||
options.last_modified_time, options.header
|
options.last_modified_time,
|
||||||
|
options.header,
|
||||||
|
get_message("pr-page")
|
||||||
);
|
);
|
||||||
vec![
|
vec![
|
||||||
String::new(),
|
String::new(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue