diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index e14e83921..37bf01e32 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -5,24 +5,25 @@ pub mod base_common; -use base_common::ReadSeek; use clap::Command; -use uucore::{encoding::Format, error::UResult, help_about, help_usage}; - -const ABOUT: &str = help_about!("base32.md"); -const USAGE: &str = help_usage!("base32.md"); +use uucore::{encoding::Format, error::UResult, locale::get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let format = Format::Base32; - - let config = base_common::parse_base_cmd_args(args, ABOUT, USAGE)?; - - let mut input: Box = base_common::get_input(&config)?; - + let (about, usage) = get_info(); + let config = base_common::parse_base_cmd_args(args, about, usage)?; + let mut input = base_common::get_input(&config)?; base_common::handle_input(&mut input, format, config) } pub fn uu_app() -> Command { - base_common::base_app(ABOUT, USAGE) + let (about, usage) = get_info(); + base_common::base_app(about, usage) +} + +fn get_info() -> (&'static str, &'static str) { + let about: &'static str = Box::leak(get_message("base32-about").into_boxed_str()); + let usage: &'static str = Box::leak(get_message("base32-usage").into_boxed_str()); + (about, usage) } diff --git a/src/uu/base64/src/base64.rs b/src/uu/base64/src/base64.rs index 86eb75bf1..cd3ab66bd 100644 --- a/src/uu/base64/src/base64.rs +++ b/src/uu/base64/src/base64.rs @@ -5,22 +5,24 @@ use clap::Command; use uu_base32::base_common; -use uucore::{encoding::Format, error::UResult, help_about, help_usage}; - -const ABOUT: &str = help_about!("base64.md"); -const USAGE: &str = help_usage!("base64.md"); +use uucore::{encoding::Format, error::UResult, locale::get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let format = Format::Base64; - - let config = base_common::parse_base_cmd_args(args, ABOUT, USAGE)?; - + let (about, usage) = get_info(); + let config = base_common::parse_base_cmd_args(args, about, usage)?; let mut input = base_common::get_input(&config)?; - base_common::handle_input(&mut input, format, config) } pub fn uu_app() -> Command { - base_common::base_app(ABOUT, USAGE) + let (about, usage) = get_info(); + base_common::base_app(about, usage) +} + +fn get_info() -> (&'static str, &'static str) { + let about: &'static str = Box::leak(get_message("base64-about").into_boxed_str()); + let usage: &'static str = Box::leak(get_message("base64-usage").into_boxed_str()); + (about, usage) } diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index a40fcc185..62046a15d 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -12,9 +12,7 @@ use uucore::error::{UResult, UUsageError}; use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; -static ABOUT: &str = help_about!("basename.md"); - -const USAGE: &str = help_usage!("basename.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static MULTIPLE: &str = "multiple"; @@ -77,8 +75,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("basename-about")) + .override_usage(format_usage(&get_message("basename-usage"))) .infer_long_args(true) .arg( Arg::new(options::MULTIPLE) diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index 100907652..9da71e9de 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -8,15 +8,11 @@ use clap::{Arg, ArgAction, Command}; use uu_base32::base_common::{self, BASE_CMD_PARSE_ERROR, Config}; use uucore::error::UClapError; +use uucore::locale::get_message; use uucore::{ encoding::Format, error::{UResult, UUsageError}, }; -use uucore::{help_about, help_usage}; - -const ABOUT: &str = help_about!("basenc.md"); -const USAGE: &str = help_usage!("basenc.md"); - const ENCODINGS: &[(&str, Format, &str)] = &[ ("base64", Format::Base64, "same as 'base64' program"), ("base64url", Format::Base64Url, "file- and url-safe base64"), @@ -47,7 +43,10 @@ const ENCODINGS: &[(&str, Format, &str)] = &[ ]; pub fn uu_app() -> Command { - let mut command = base_common::base_app(ABOUT, USAGE); + let about: &'static str = Box::leak(get_message("basenc-about").into_boxed_str()); + let usage: &'static str = Box::leak(get_message("basenc-usage").into_boxed_str()); + + let mut command = base_common::base_app(about, usage); for encoding in ENCODINGS { let raw_arg = Arg::new(encoding.0) .long(encoding.0) diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 45fbe6ceb..d60262e1d 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -30,8 +30,7 @@ use uucore::{fast_inc::fast_inc_one, format_usage, help_about, help_usage}; #[cfg(any(target_os = "linux", target_os = "android"))] mod splice; -const USAGE: &str = help_usage!("cat.md"); -const ABOUT: &str = help_about!("cat.md"); +use uucore::locale::{self, get_message}; // Allocate 32 digits for the line number. // An estimate is that we can print about 1e8 lines/seconds, so 32 digits @@ -275,8 +274,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("cat-usage"))) + .about(get_message("cat-about")) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 2b1ff2e8f..eaf820d2d 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -24,8 +24,7 @@ mod fts; use errors::*; -const ABOUT: &str = help_about!("chcon.md"); -const USAGE: &str = help_usage!("chcon.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static HELP: &str = "help"; @@ -151,8 +150,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("chcon-about")) + .override_usage(format_usage(&get_message("chcon-usage"))) .infer_long_args(true) .disable_help_flag(true) .args_override_self(true) diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index 1763bbfeb..fa5daedb9 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -16,8 +16,7 @@ use clap::{Arg, ArgAction, ArgMatches, Command}; use std::fs; use std::os::unix::fs::MetadataExt; -const ABOUT: &str = help_about!("chgrp.md"); -const USAGE: &str = help_usage!("chgrp.md"); +use uucore::locale::{self, get_message}; fn parse_gid_from_str(group: &str) -> Result { if let Some(gid_str) = group.strip_prefix(':') { @@ -99,8 +98,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("chgrp-about")) + .override_usage(format_usage(&get_message("chgrp-usage"))) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index dfe304859..b899a237c 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -19,8 +19,7 @@ use uucore::mode; use uucore::perms::{TraverseSymlinks, configure_symlink_and_recursion}; use uucore::{format_usage, help_about, help_section, help_usage, show, show_error}; -const ABOUT: &str = help_about!("chmod.md"); -const USAGE: &str = help_usage!("chmod.md"); +use uucore::locale::{self, get_message}; const LONG_USAGE: &str = help_section!("after help", "chmod.md"); mod options { @@ -159,8 +158,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("chmod-about")) + .override_usage(format_usage(&get_message("chmod-usage"))) .args_override_self(true) .infer_long_args(true) .no_binary_name(true) diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 4389d92f6..af6cbc843 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -17,9 +17,7 @@ use clap::{Arg, ArgAction, ArgMatches, Command}; use std::fs; use std::os::unix::fs::MetadataExt; -static ABOUT: &str = help_about!("chown.md"); - -const USAGE: &str = help_usage!("chown.md"); +use uucore::locale::{self, get_message}; fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult { let filter = if let Some(spec) = matches.get_one::(options::FROM) { @@ -79,8 +77,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("chown-about")) + .override_usage(format_usage(&get_message("chown-usage"))) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 15c7bac4d..48c5de17b 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -19,7 +19,7 @@ use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; use uucore::libc::{self, chroot, setgid, setgroups, setuid}; use uucore::{format_usage, help_about, help_usage, show}; -static ABOUT: &str = help_about!("chroot.md"); +use uucore::locale::{self, get_message}; static USAGE: &str = help_usage!("chroot.md"); mod options { @@ -237,8 +237,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("chroot-about")) + .override_usage(format_usage(&get_message("chroot-usage"))) .infer_long_args(true) .trailing_var_arg(true) .arg( diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index a1a9115d9..053257997 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -26,9 +26,7 @@ use uucore::{ sum::Digest, }; -const USAGE: &str = help_usage!("cksum.md"); -const ABOUT: &str = help_about!("cksum.md"); -const AFTER_HELP: &str = help_section!("after help", "cksum.md"); +use uucore::locale::{self, get_message}; #[derive(Debug, PartialEq)] enum OutputFormat { @@ -343,8 +341,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("cksum-about")) + .override_usage(format_usage(&get_message("cksum-usage"))) .infer_long_args(true) .args_override_self(true) .arg( @@ -468,7 +466,7 @@ pub fn uu_app() -> Command { ) .action(ArgAction::SetTrue), ) - .after_help(AFTER_HELP) + .after_help(get_message("cksum-after-help")) } #[cfg(test)] diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 11752c331..c67b8665a 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -15,8 +15,7 @@ use uucore::{format_usage, help_about, help_usage}; use clap::{Arg, ArgAction, ArgMatches, Command}; -const ABOUT: &str = help_about!("comm.md"); -const USAGE: &str = help_usage!("comm.md"); +use uucore::locale::{self, get_message}; mod options { pub const COLUMN_1: &str = "1"; @@ -314,8 +313,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("comm-about")) + .override_usage(format_usage(&get_message("comm-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 7ca39f6e3..37c2367cd 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -451,9 +451,7 @@ fn show_debug(copy_debug: &CopyDebug) { ); } -const ABOUT: &str = help_about!("cp.md"); -const USAGE: &str = help_usage!("cp.md"); -const AFTER_HELP: &str = help_section!("after help", "cp.md"); +use uucore::locale::{self, get_message}; static EXIT_ERR: i32 = 1; @@ -523,10 +521,11 @@ pub fn uu_app() -> Command { ]; Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("cp-about")) + .override_usage(format_usage(&get_message("cp-usage"))) .after_help(format!( - "{AFTER_HELP}\n\n{}", + "{}\n\n{}", + get_message("cp-after-help"), backup_control::BACKUP_CONTROL_LONG_HELP )) .infer_long_args(true) diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 621823aeb..ed025da62 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -25,9 +25,7 @@ mod split_name; use crate::csplit_error::CsplitError; use crate::split_name::SplitName; -const ABOUT: &str = help_about!("csplit.md"); -const AFTER_HELP: &str = help_section!("after help", "csplit.md"); -const USAGE: &str = help_usage!("csplit.md"); +use uucore::locale::{self, get_message}; mod options { pub const SUFFIX_FORMAT: &str = "suffix-format"; @@ -631,8 +629,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("csplit-about")) + .override_usage(format_usage(&get_message("csplit-usage"))) .args_override_self(true) .infer_long_args(true) .arg( @@ -697,7 +695,7 @@ pub fn uu_app() -> Command { .action(ArgAction::Append) .required(true), ) - .after_help(AFTER_HELP) + .after_help(get_message("csplit-after-help")) } #[cfg(test)] diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 49f5445f3..4d9241b68 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -24,9 +24,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_error, sho mod matcher; mod searcher; -const USAGE: &str = help_usage!("cut.md"); -const ABOUT: &str = help_about!("cut.md"); -const AFTER_HELP: &str = help_section!("after help", "cut.md"); +use uucore::locale::{self, get_message}; struct Options<'a> { out_delimiter: Option<&'a [u8]>, @@ -580,9 +578,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) - .after_help(AFTER_HELP) + .override_usage(format_usage(&get_message("cut-usage"))) + .about(get_message("cut-about")) + .after_help(get_message("cut-after-help")) .infer_long_args(true) // While `args_override_self(true)` for some arguments, such as `-d` // and `--output-delimiter`, is consistent to the behavior of GNU cut, diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index aff353fee..a2e5be2d0 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -30,8 +30,7 @@ const MINUTES: &str = "minutes"; const SECONDS: &str = "seconds"; const NS: &str = "ns"; -const ABOUT: &str = help_about!("date.md"); -const USAGE: &str = help_usage!("date.md"); +use uucore::locale::{self, get_message}; const OPT_DATE: &str = "date"; const OPT_FORMAT: &str = "format"; @@ -290,8 +289,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("date-about")) + .override_usage(format_usage(&get_message("date-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_DATE) diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 4de05246f..3c1d1e428 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -62,9 +62,7 @@ use uucore::error::{USimpleError, set_exit_code}; use uucore::show_if_err; use uucore::{format_usage, help_about, help_section, help_usage, show_error}; -const ABOUT: &str = help_about!("dd.md"); -const AFTER_HELP: &str = help_section!("after help", "dd.md"); -const USAGE: &str = help_usage!("dd.md"); +use uucore::locale::{self, get_message}; const BUF_INIT_BYTE: u8 = 0xDD; /// Final settings after parsing @@ -1427,9 +1425,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("dd-about")) + .override_usage(format_usage(&get_message("dd-usage"))) + .after_help(get_message("dd-after-help")) .infer_long_args(true) .arg(Arg::new(options::OPERANDS).num_args(1..)) } diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 9e2bb6920..c5d1a5aa4 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -29,9 +29,7 @@ use crate::filesystem::Filesystem; use crate::filesystem::FsError; use crate::table::Table; -const ABOUT: &str = help_about!("df.md"); -const USAGE: &str = help_usage!("df.md"); -const AFTER_HELP: &str = help_section!("after help", "df.md"); +use uucore::locale::{self, get_message}; static OPT_HELP: &str = "help"; static OPT_ALL: &str = "all"; @@ -452,9 +450,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("df-about")) + .override_usage(format_usage(&get_message("df-usage"))) + .after_help(get_message("df-after-help")) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 4fb9228eb..ea5d50825 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -26,9 +26,7 @@ mod options { pub const FILE: &str = "FILE"; } -const USAGE: &str = help_usage!("dircolors.md"); -const ABOUT: &str = help_about!("dircolors.md"); -const AFTER_HELP: &str = help_section!("after help", "dircolors.md"); +use uucore::locale::{self, get_message}; #[derive(PartialEq, Eq, Debug)] pub enum OutputFmt { @@ -245,9 +243,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("dircolors-about")) + .after_help(get_message("dircolors-after-help")) + .override_usage(format_usage(&get_message("dircolors-usage"))) .args_override_self(true) .infer_long_args(true) .arg( diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index de8740f89..5eb6ca4b3 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -10,9 +10,7 @@ use uucore::error::{UResult, UUsageError}; use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("dirname.md"); -const USAGE: &str = help_usage!("dirname.md"); -const AFTER_HELP: &str = help_section!("after help", "dirname.md"); +use uucore::locale::{self, get_message}; mod options { pub const ZERO: &str = "zero"; @@ -21,7 +19,9 @@ mod options { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; + let matches = uu_app() + .after_help(get_message("dirname-after-help")) + .try_get_matches_from(args)?; let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO)); @@ -61,9 +61,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) + .about(get_message("dirname-about")) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) + .override_usage(format_usage(&get_message("dirname-usage"))) .args_override_self(true) .infer_long_args(true) .arg( diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 0b2688881..c25d66f5d 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -70,9 +70,7 @@ mod options { pub const FILE: &str = "FILE"; } -const ABOUT: &str = help_about!("du.md"); -const AFTER_HELP: &str = help_section!("after help", "du.md"); -const USAGE: &str = help_usage!("du.md"); +use uucore::locale::{self, get_message}; struct TraversalOptions { all: bool, @@ -824,9 +822,9 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("du-about")) + .after_help(get_message("du-after-help")) + .override_usage(format_usage(&get_message("du-usage"))) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 4df766348..b6e699ce2 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -12,9 +12,7 @@ use uucore::error::{UResult, USimpleError}; use uucore::format::{FormatChar, OctalParsing, parse_escape_only}; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("echo.md"); -const USAGE: &str = help_usage!("echo.md"); -const AFTER_HELP: &str = help_section!("after help", "echo.md"); +use uucore::locale::{self, get_message}; mod options { pub const STRING: &str = "STRING"; @@ -141,9 +139,9 @@ pub fn uu_app() -> Command { .trailing_var_arg(true) .allow_hyphen_values(true) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("echo-about")) + .after_help(get_message("echo-after-help")) + .override_usage(format_usage(&get_message("echo-usage"))) .arg( Arg::new(options::NO_NEWLINE) .short('n') diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 51479b590..0555dbe60 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -74,9 +74,7 @@ impl From for EnvError { } } -const ABOUT: &str = help_about!("env.md"); -const USAGE: &str = help_usage!("env.md"); -const AFTER_HELP: &str = help_section!("after help", "env.md"); +use uucore::locale::{self, get_message}; mod options { pub const IGNORE_ENVIRONMENT: &str = "ignore-environment"; @@ -222,9 +220,9 @@ fn load_config_file(opts: &mut Options) -> UResult<()> { pub fn uu_app() -> Command { Command::new(crate_name!()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("env-about")) + .override_usage(format_usage(&get_message("env-usage"))) + .after_help(get_message("env-after-help")) .infer_long_args(true) .trailing_var_arg(true) .arg( diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 4c37393b4..a7cb0928c 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -18,8 +18,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, set_exit_code}; use uucore::{format_usage, help_about, help_usage, show_error}; -const ABOUT: &str = help_about!("expand.md"); -const USAGE: &str = help_usage!("expand.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static TABS: &str = "tabs"; @@ -253,9 +252,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) + .about(get_message("expand-about")) .after_help(LONG_HELP) - .override_usage(format_usage(USAGE)) + .override_usage(format_usage(&get_message("expand-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 2c8d1661c..f00d05eca 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -16,8 +16,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, set_exit_code}; use uucore::{format_usage, help_about, help_usage, show_error, show_warning}; -const ABOUT: &str = help_about!("factor.md"); -const USAGE: &str = help_usage!("factor.md"); +use uucore::locale::{self, get_message}; mod options { pub static EXPONENTS: &str = "exponents"; @@ -122,8 +121,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("factor-about")) + .override_usage(format_usage(&get_message("factor-usage"))) .infer_long_args(true) .disable_help_flag(true) .args_override_self(true) diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index adf3593ea..a1e15ba42 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -7,7 +7,7 @@ use std::{ffi::OsString, io::Write}; use uucore::error::{UResult, set_exit_code}; use uucore::help_about; -const ABOUT: &str = help_about!("false.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -46,7 +46,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) + .about(get_message("false-about")) // We provide our own help and version options, to ensure maximum compatibility with GNU. .disable_help_flag(true) .disable_version_flag(true) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 8366af6cd..f8d5cdfa8 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -18,8 +18,7 @@ use parasplit::ParagraphStream; mod linebreak; mod parasplit; -const ABOUT: &str = help_about!("fmt.md"); -const USAGE: &str = help_usage!("fmt.md"); +use uucore::locale::{self, get_message}; const MAX_WIDTH: usize = 2500; const DEFAULT_GOAL: usize = 70; const DEFAULT_WIDTH: usize = 75; @@ -336,8 +335,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("fmt-about")) + .override_usage(format_usage(&get_message("fmt-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index 0aba9c57e..1735c5642 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -15,8 +15,7 @@ use uucore::{format_usage, help_about, help_usage}; const TAB_WIDTH: usize = 8; -const USAGE: &str = help_usage!("fold.md"); -const ABOUT: &str = help_about!("fold.md"); +use uucore::locale::{self, get_message}; mod options { pub const BYTES: &str = "bytes"; @@ -60,8 +59,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("fold-usage"))) + .about(get_message("fold-about")) .infer_long_args(true) .arg( Arg::new(options::BYTES) diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index 6f7fbf5fe..dc2e7a631 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -18,8 +18,7 @@ use clap::{Arg, ArgAction, Command}; mod options { pub const USERS: &str = "USERNAME"; } -const ABOUT: &str = help_about!("groups.md"); -const USAGE: &str = help_usage!("groups.md"); +use uucore::locale::{self, get_message}; #[derive(Debug, Error)] enum GroupsError { @@ -82,8 +81,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("groups-about")) + .override_usage(format_usage(&get_message("groups-usage"))) .infer_long_args(true) .arg( Arg::new(options::USERS) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index cd8ca912d..2a81a0b56 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -30,8 +30,7 @@ use uucore::sum::{Digest, Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shak use uucore::{format_usage, help_about, help_usage}; const NAME: &str = "hashsum"; -const ABOUT: &str = help_about!("hashsum.md"); -const USAGE: &str = help_usage!("hashsum.md"); +use uucore::locale::{self, get_message}; struct Options { algoname: &'static str, @@ -318,8 +317,8 @@ pub fn uu_app_common() -> Command { const TEXT_HELP: &str = "read in text mode (default)"; Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("hashsum-about")) + .override_usage(format_usage(&get_message("hashsum-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 573926a7b..35fe46112 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -20,8 +20,7 @@ use uucore::{format_usage, help_about, help_usage, show}; const BUF_SIZE: usize = 65536; -const ABOUT: &str = help_about!("head.md"); -const USAGE: &str = help_usage!("head.md"); +use uucore::locale::{self, get_message}; mod options { pub const BYTES_NAME: &str = "BYTES"; @@ -72,8 +71,8 @@ type HeadResult = Result; pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("head-about")) + .override_usage(format_usage(&get_message("head-usage"))) .infer_long_args(true) .arg( Arg::new(options::BYTES_NAME) diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index a01151dde..cee59b7b0 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -9,8 +9,7 @@ use clap::Command; use libc::{c_long, gethostid}; use uucore::{error::UResult, format_usage, help_about, help_usage}; -const USAGE: &str = help_usage!("hostid.md"); -const ABOUT: &str = help_about!("hostid.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -22,8 +21,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("hostid-about")) + .override_usage(format_usage(&get_message("hostid-usage"))) .infer_long_args(true) } diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 29b2bb6ba..514e3db1f 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -21,8 +21,7 @@ use uucore::{ format_usage, help_about, help_usage, }; -const ABOUT: &str = help_about!("hostname.md"); -const USAGE: &str = help_usage!("hostname.md"); +use uucore::locale::{self, get_message}; static OPT_DOMAIN: &str = "domain"; static OPT_IP_ADDRESS: &str = "ip-address"; @@ -76,8 +75,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("hostname-about")) + .override_usage(format_usage(&get_message("hostname-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_DOMAIN) diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 314d12d68..413ba06b3 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -59,9 +59,7 @@ macro_rules! cstr2cow { }; } -const ABOUT: &str = help_about!("id.md"); -const USAGE: &str = help_usage!("id.md"); -const AFTER_HELP: &str = help_section!("after help", "id.md"); +use uucore::locale::{self, get_message}; #[cfg(not(feature = "selinux"))] static CONTEXT_HELP_TEXT: &str = "print only the security context of the process (not enabled)"; @@ -119,7 +117,9 @@ struct State { #[uucore::main] #[allow(clippy::cognitive_complexity)] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; + let matches = uu_app() + .after_help(get_message("id-after-help")) + .try_get_matches_from(args)?; let users: Vec = matches .get_many::(options::ARG_USERS) @@ -327,8 +327,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("id-about")) + .override_usage(format_usage(&get_message("id-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index c4590240b..3bfd542c1 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -140,8 +140,7 @@ impl Behavior { } } -const ABOUT: &str = help_about!("install.md"); -const USAGE: &str = help_usage!("install.md"); +use uucore::locale::{self, get_message}; static OPT_COMPARE: &str = "compare"; static OPT_DIRECTORY: &str = "directory"; @@ -185,8 +184,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("install-about")) + .override_usage(format_usage(&get_message("install-usage"))) .infer_long_args(true) .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) @@ -516,7 +515,11 @@ fn standard(mut paths: Vec, b: &Behavior) -> UResult<()> { return Err(UUsageError::new(1, "missing file operand")); } if b.no_target_dir && paths.len() > 2 { - return Err(InstallError::ExtraOperand(paths[2].clone(), format_usage(USAGE)).into()); + return Err(InstallError::ExtraOperand( + paths[2].clone(), + format_usage(&get_message("install-usage")), + ) + .into()); } // get the target from either "-t foo" param or from the last given paths argument diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 0c6816cb6..838cce325 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -21,8 +21,7 @@ use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code}; use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("join.md"); -const USAGE: &str = help_usage!("join.md"); +use uucore::locale::{self, get_message}; #[derive(Debug, Error)] enum JoinError { @@ -855,8 +854,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("join-about")) + .override_usage(format_usage(&get_message("join-usage"))) .infer_long_args(true) .arg( Arg::new("a") diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index 8d8aa0b61..8d78edd98 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -14,8 +14,7 @@ use uucore::error::{FromIo, UResult, USimpleError}; use uucore::signals::{ALL_SIGNALS, signal_by_name_or_value, signal_name_by_value}; use uucore::{format_usage, help_about, help_usage, show}; -static ABOUT: &str = help_about!("kill.md"); -const USAGE: &str = help_usage!("kill.md"); +use uucore::locale::{self, get_message}; // When the -l option is selected, the program displays the type of signal related to a certain // value or string. In case of a value, the program should control the lower 8 bits, but there is @@ -104,8 +103,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("kill-about")) + .override_usage(format_usage(&get_message("kill-usage"))) .infer_long_args(true) .allow_negative_numbers(true) .arg( diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 31f1239d8..1fcb0186f 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -11,8 +11,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; use uucore::{format_usage, help_about, help_usage}; -static ABOUT: &str = help_about!("link.md"); -const USAGE: &str = help_usage!("link.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static FILES: &str = "FILES"; @@ -36,8 +35,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("link-about")) + .override_usage(format_usage(&get_message("link-usage"))) .infer_long_args(true) .arg( Arg::new(options::FILES) diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index c46407648..ec3c2638e 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -70,9 +70,7 @@ impl UError for LnError { } } -const ABOUT: &str = help_about!("ln.md"); -const USAGE: &str = help_usage!("ln.md"); -const AFTER_HELP: &str = help_section!("after help", "ln.md"); +use uucore::locale::{self, get_message}; mod options { pub const FORCE: &str = "force"; @@ -93,7 +91,8 @@ static ARG_FILES: &str = "files"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = format!( - "{AFTER_HELP}\n\n{}", + "{}\n\n{}", + get_message("ln-after-help"), backup_control::BACKUP_CONTROL_LONG_HELP ); @@ -144,8 +143,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("ln-about")) + .override_usage(format_usage(&get_message("ln-usage"))) .infer_long_args(true) .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 5437bbae3..a6cdde7df 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -25,8 +25,7 @@ fn get_userlogin() -> Option { } } -const ABOUT: &str = help_about!("logname.md"); -const USAGE: &str = help_usage!("logname.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -43,7 +42,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(uucore::util_name()) + .about(get_message("logname-about")) .infer_long_args(true) } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index b2c98689d..33975b217 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -82,9 +82,7 @@ static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not e #[cfg(feature = "selinux")] static CONTEXT_HELP_TEXT: &str = "print any security context of each file"; -const ABOUT: &str = help_about!("ls.md"); -const AFTER_HELP: &str = help_section!("after help", "ls.md"); -const USAGE: &str = help_usage!("ls.md"); +use uucore::locale::{self, get_message}; pub mod options { pub mod format { @@ -1179,8 +1177,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("ls-usage"))) + .about(get_message("ls-about")) .infer_long_args(true) .disable_help_flag(true) .args_override_self(true) @@ -1869,7 +1867,7 @@ pub fn uu_app() -> Command { .value_hint(clap::ValueHint::AnyPath) .value_parser(ValueParser::os_string()), ) - .after_help(AFTER_HELP) + .after_help(get_message("ls-after-help")) } /// Represents a Path along with it's associated data. diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index adef62eee..6c181e55f 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -20,9 +20,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_if_err}; static DEFAULT_PERM: u32 = 0o777; -const ABOUT: &str = help_about!("mkdir.md"); -const USAGE: &str = help_usage!("mkdir.md"); -const AFTER_HELP: &str = help_section!("after help", "mkdir.md"); +use uucore::locale::{self, get_message}; mod options { pub const MODE: &str = "mode"; @@ -103,7 +101,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // Linux-specific options, not implemented // opts.optflag("Z", "context", "set SELinux security context" + // " of each created directory to CTX"), - let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; + let matches = uu_app() + .after_help(get_message("mkdir-after-help")) + .try_get_matches_from(args)?; let dirs = matches .get_many::(options::DIRS) @@ -133,8 +133,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("mkdir-about")) + .override_usage(format_usage(&get_message("mkdir-usage"))) .infer_long_args(true) .arg( Arg::new(options::MODE) diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index 24c057ebc..7d3df867d 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -13,7 +13,7 @@ use uucore::error::{UResult, USimpleError}; use uucore::{format_usage, help_about, help_usage, show}; static USAGE: &str = help_usage!("mkfifo.md"); -static ABOUT: &str = help_about!("mkfifo.md"); +use uucore::locale::{self, get_message}; mod options { pub static MODE: &str = "mode"; @@ -86,8 +86,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("mkfifo-usage"))) + .about(get_message("mkfifo-about")) .infer_long_args(true) .arg( Arg::new(options::MODE) diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index 076e639cc..801b2256a 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -14,9 +14,7 @@ use uucore::display::Quotable; use uucore::error::{UResult, USimpleError, UUsageError, set_exit_code}; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("mknod.md"); -const USAGE: &str = help_usage!("mknod.md"); -const AFTER_HELP: &str = help_section!("after help", "mknod.md"); +use uucore::locale::{self, get_message}; const MODE_RW_UGO: mode_t = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; @@ -159,9 +157,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) - .about(ABOUT) + .override_usage(format_usage(&get_message("mknod-usage"))) + .after_help(get_message("mknod-after-help")) + .about(get_message("mknod-about")) .infer_long_args(true) .arg( Arg::new(options::MODE) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index d689115a6..21f61660f 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -25,8 +25,7 @@ use rand::Rng; use tempfile::Builder; use thiserror::Error; -const ABOUT: &str = help_about!("mktemp.md"); -const USAGE: &str = help_usage!("mktemp.md"); +use uucore::locale::{self, get_message}; static DEFAULT_TEMPLATE: &str = "tmp.XXXXXXXXXX"; @@ -347,8 +346,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("mktemp-about")) + .override_usage(format_usage(&get_message("mktemp-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_DIRECTORY) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 97d911f4f..c07846d19 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -26,8 +26,7 @@ use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::{display::Quotable, show}; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("more.md"); -const USAGE: &str = help_usage!("more.md"); +use uucore::locale::{self, get_message}; const BELL: char = '\x07'; // Printing this character will ring the bell // The prompt to be displayed at the top of the screen when viewing multiple files, @@ -155,8 +154,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("more-about")) + .override_usage(format_usage(&get_message("more-usage"))) .version(uucore::crate_version!()) .infer_long_args(true) .arg( diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index edfa505c5..195c79e11 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -123,9 +123,7 @@ pub enum OverwriteMode { Force, } -const ABOUT: &str = help_about!("mv.md"); -const USAGE: &str = help_usage!("mv.md"); -const AFTER_HELP: &str = help_section!("after help", "mv.md"); +use uucore::locale::{self, get_message}; static OPT_FORCE: &str = "force"; static OPT_INTERACTIVE: &str = "interactive"; @@ -205,10 +203,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("mv-about")) + .override_usage(format_usage(&get_message("mv-usage"))) .after_help(format!( - "{AFTER_HELP}\n\n{}", + "{}\n\n{}", + get_message("mv-after-help"), backup_control::BACKUP_CONTROL_LONG_HELP )) .infer_long_args(true) diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 05ae2fa94..927d9ad4b 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -21,8 +21,7 @@ pub mod options { pub static COMMAND: &str = "COMMAND"; } -const ABOUT: &str = help_about!("nice.md"); -const USAGE: &str = help_usage!("nice.md"); +use uucore::locale::{self, get_message}; fn is_prefix_of(maybe_prefix: &str, target: &str, min_match: usize) -> bool { if maybe_prefix.len() < min_match || maybe_prefix.len() > target.len() { @@ -186,8 +185,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("nice-about")) + .override_usage(format_usage(&get_message("nice-usage"))) .trailing_var_arg(true) .infer_long_args(true) .version(uucore::crate_version!()) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 6380417e0..370d9e780 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -12,9 +12,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_error}; mod helper; -const ABOUT: &str = help_about!("nl.md"); -const AFTER_HELP: &str = help_section!("after help", "nl.md"); -const USAGE: &str = help_usage!("nl.md"); +use uucore::locale::{self, get_message}; // Settings store options used by nl to produce its output. pub struct Settings { @@ -222,10 +220,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) + .about(get_message("nl-about")) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .override_usage(format_usage(&get_message("nl-usage"))) + .after_help(get_message("nl-after-help")) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 73003a164..4fa8ed37e 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -19,9 +19,7 @@ use uucore::display::Quotable; use uucore::error::{UClapError, UError, UResult, set_exit_code}; use uucore::{format_usage, help_about, help_section, help_usage, show_error}; -const ABOUT: &str = help_about!("nohup.md"); -const AFTER_HELP: &str = help_section!("after help", "nohup.md"); -const USAGE: &str = help_usage!("nohup.md"); +use uucore::locale::{self, get_message}; static NOHUP_OUT: &str = "nohup.out"; // exit codes that match the GNU implementation static EXIT_CANCELED: i32 = 125; @@ -92,9 +90,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("nohup-about")) + .after_help(get_message("nohup-after-help")) + .override_usage(format_usage(&get_message("nohup-usage"))) .arg( Arg::new(options::CMD) .hide(true) diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index a3a80724d..008cd0050 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -23,8 +23,7 @@ pub const _SC_NPROCESSORS_CONF: libc::c_int = 1001; static OPT_ALL: &str = "all"; static OPT_IGNORE: &str = "ignore"; -const ABOUT: &str = help_about!("nproc.md"); -const USAGE: &str = help_usage!("nproc.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -94,8 +93,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("nproc-about")) + .override_usage(format_usage(&get_message("nproc-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_ALL) diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index cfa7c30d8..c82ff9453 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -24,9 +24,7 @@ pub mod format; pub mod options; mod units; -const ABOUT: &str = help_about!("numfmt.md"); -const AFTER_HELP: &str = help_section!("after help", "numfmt.md"); -const USAGE: &str = help_usage!("numfmt.md"); +use uucore::locale::{self, get_message}; fn handle_args<'a>(args: impl Iterator, options: &NumfmtOptions) -> UResult<()> { for l in args { @@ -277,9 +275,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("numfmt-about")) + .after_help(get_message("numfmt-after-help")) + .override_usage(format_usage(&get_message("numfmt-usage"))) .allow_negative_numbers(true) .infer_long_args(true) .arg( diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 652a0ce3f..1a728c937 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -50,9 +50,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_error, sho const PEEK_BUFFER_SIZE: usize = 4; // utf-8 can be 4 bytes -const ABOUT: &str = help_about!("od.md"); -const USAGE: &str = help_usage!("od.md"); -const AFTER_HELP: &str = help_section!("after help", "od.md"); +use uucore::locale::{self, get_message}; pub(crate) mod options { pub const HELP: &str = "help"; @@ -253,9 +251,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("od-about")) + .override_usage(format_usage(&get_message("od-usage"))) + .after_help(get_message("od-after-help")) .trailing_var_arg(true) .dont_delimit_trailing_values(true) .infer_long_args(true) diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 98679b746..64c27384e 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -14,8 +14,7 @@ use uucore::error::{UResult, USimpleError}; use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("paste.md"); -const USAGE: &str = help_usage!("paste.md"); +use uucore::locale::{self, get_message}; mod options { pub const DELIMITER: &str = "delimiters"; @@ -43,8 +42,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("paste-about")) + .override_usage(format_usage(&get_message("paste-usage"))) .infer_long_args(true) .arg( Arg::new(options::SERIAL) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 183d67a0b..d27df4c51 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -20,8 +20,7 @@ enum Mode { Both, // a combination of `Basic` and `Extra` } -const ABOUT: &str = help_about!("pathchk.md"); -const USAGE: &str = help_usage!("pathchk.md"); +use uucore::locale::{self, get_message}; mod options { pub const POSIX: &str = "posix"; @@ -80,8 +79,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("pathchk-about")) + .override_usage(format_usage(&get_message("pathchk-usage"))) .infer_long_args(true) .arg( Arg::new(options::POSIX) diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 8246f8655..5b1ea9ddf 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -20,9 +20,7 @@ const ABOUT: &str = concat!( ); #[cfg(not(target_env = "musl"))] -const ABOUT: &str = help_about!("pinky.md"); - -const USAGE: &str = help_usage!("pinky.md"); +use uucore::locale::{self, get_message}; mod options { pub const LONG_FORMAT: &str = "long_format"; @@ -44,8 +42,8 @@ use platform::uumain; pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("pinky-about")) + .override_usage(format_usage(&get_message("pinky-usage"))) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index e24f9cf18..0741f17c5 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -20,9 +20,7 @@ use uucore::display::Quotable; use uucore::error::UResult; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("pr.md"); -const USAGE: &str = help_usage!("pr.md"); -const AFTER_HELP: &str = help_section!("after help", "pr.md"); +use uucore::locale::{self, get_message}; const TAB: char = '\t'; const LINES_PER_PAGE: usize = 66; const LINES_PER_PAGE_FOR_FORM_FEED: usize = 63; @@ -153,9 +151,9 @@ enum PrError { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("pr-about")) + .after_help(get_message("pr-after-help")) + .override_usage(format_usage(&get_message("pr-usage"))) .infer_long_args(true) .args_override_self(true) .disable_help_flag(true) diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index 4584a09b8..85925bf8f 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -7,8 +7,7 @@ use clap::{Arg, ArgAction, Command}; use std::env; use uucore::{error::UResult, format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("printenv.md"); -const USAGE: &str = help_usage!("printenv.md"); +use uucore::locale::{self, get_message}; static OPT_NULL: &str = "null"; @@ -56,8 +55,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("printenv-about")) + .override_usage(format_usage(&get_message("printenv-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_NULL) diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index 887ad4107..bc36305cc 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -11,9 +11,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, os_str_as_bytes const VERSION: &str = "version"; const HELP: &str = "help"; -const USAGE: &str = help_usage!("printf.md"); -const ABOUT: &str = help_about!("printf.md"); -const AFTER_HELP: &str = help_section!("after help", "printf.md"); +use uucore::locale::{self, get_message}; mod options { pub const FORMAT: &str = "FORMAT"; @@ -81,9 +79,9 @@ pub fn uu_app() -> Command { Command::new(uucore::util_name()) .allow_hyphen_values(true) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("printf-about")) + .after_help(get_message("printf-after-help")) + .override_usage(format_usage(&get_message("printf-usage"))) .disable_help_flag(true) .disable_version_flag(true) .arg( diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index bb5b29282..82e7cec52 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -19,8 +19,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, UUsageError}; use uucore::{format_usage, help_about, help_usage}; -const USAGE: &str = help_usage!("ptx.md"); -const ABOUT: &str = help_about!("ptx.md"); +use uucore::locale::{self, get_message}; #[derive(Debug)] enum OutFormat { @@ -765,9 +764,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) + .about(get_message("ptx-about")) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) + .override_usage(format_usage(&get_message("ptx-usage"))) .infer_long_args(true) .arg( Arg::new(options::FILE) diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index b924af241..b7d9ea69d 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -13,8 +13,7 @@ use uucore::{format_usage, help_about, help_usage}; use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; -const ABOUT: &str = help_about!("pwd.md"); -const USAGE: &str = help_usage!("pwd.md"); +use uucore::locale::{self, get_message}; const OPT_LOGICAL: &str = "logical"; const OPT_PHYSICAL: &str = "physical"; @@ -141,8 +140,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("pwd-about")) + .override_usage(format_usage(&get_message("pwd-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_LOGICAL) diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index 211422e03..d05efa610 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -15,8 +15,7 @@ use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage, show_error}; -const ABOUT: &str = help_about!("readlink.md"); -const USAGE: &str = help_usage!("readlink.md"); +use uucore::locale::{self, get_message}; const OPT_CANONICALIZE: &str = "canonicalize"; const OPT_CANONICALIZE_MISSING: &str = "canonicalize-missing"; const OPT_CANONICALIZE_EXISTING: &str = "canonicalize-existing"; @@ -102,8 +101,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("readlink-about")) + .override_usage(format_usage(&get_message("readlink-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_CANONICALIZE) diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index 94532b755..3a947d9a0 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -21,8 +21,7 @@ use uucore::{ show_if_err, }; -static ABOUT: &str = help_about!("realpath.md"); -const USAGE: &str = help_usage!("realpath.md"); +use uucore::locale::{self, get_message}; static OPT_QUIET: &str = "quiet"; static OPT_STRIP: &str = "strip"; @@ -89,8 +88,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("realpath-about")) + .override_usage(format_usage(&get_message("realpath-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_QUIET) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 3f48e311b..367ae04fb 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -90,9 +90,7 @@ impl Default for Options { } } -const ABOUT: &str = help_about!("rm.md"); -const USAGE: &str = help_usage!("rm.md"); -const AFTER_HELP: &str = help_section!("after help", "rm.md"); +use uucore::locale::{self, get_message}; static OPT_DIR: &str = "dir"; static OPT_INTERACTIVE: &str = "interactive"; @@ -202,9 +200,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("rm-about")) + .override_usage(format_usage(&get_message("rm-usage"))) + .after_help(get_message("rm-after-help")) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index 8c9dc12b6..8be21e618 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -16,8 +16,7 @@ use uucore::error::{UResult, set_exit_code, strip_errno}; use uucore::{format_usage, help_about, help_usage, show_error, util_name}; -static ABOUT: &str = help_about!("rmdir.md"); -const USAGE: &str = help_usage!("rmdir.md"); +use uucore::locale::{self, get_message}; static OPT_IGNORE_FAIL_NON_EMPTY: &str = "ignore-fail-on-non-empty"; static OPT_PARENTS: &str = "parents"; static OPT_VERBOSE: &str = "verbose"; @@ -165,8 +164,8 @@ struct Opts { pub fn uu_app() -> Command { Command::new(util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("rmdir-about")) + .override_usage(format_usage(&get_message("rmdir-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_IGNORE_FAIL_NON_EMPTY) diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 658aa33b2..01f692ff3 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -23,8 +23,7 @@ mod errors; use errors::error_exit_status; use errors::{Error, Result, RunconError}; -const ABOUT: &str = help_about!("runcon.md"); -const USAGE: &str = help_usage!("runcon.md"); +use uucore::locale::{self, get_message}; const DESCRIPTION: &str = help_section!("after help", "runcon.md"); pub mod options { @@ -90,9 +89,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) + .about(get_message("runcon-about")) .after_help(DESCRIPTION) - .override_usage(format_usage(USAGE)) + .override_usage(format_usage(&get_message("runcon-usage"))) .infer_long_args(true) .arg( Arg::new(options::COMPUTE) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index af7ca2f84..bd7d9b3f2 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -28,8 +28,7 @@ mod numberparse; use crate::error::SeqError; use crate::number::PreciseNumber; -const ABOUT: &str = help_about!("seq.md"); -const USAGE: &str = help_usage!("seq.md"); +use uucore::locale::{self, get_message}; const OPT_SEPARATOR: &str = "separator"; const OPT_TERMINATOR: &str = "terminator"; @@ -222,8 +221,8 @@ pub fn uu_app() -> Command { .trailing_var_arg(true) .infer_long_args(true) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("seq-about")) + .override_usage(format_usage(&get_message("seq-usage"))) .arg( Arg::new(OPT_SEPARATOR) .short('s') diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 30777e28a..d42d652fc 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -20,9 +20,7 @@ use uucore::parser::parse_size::parse_size_u64; use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_section, help_usage, show_error, show_if_err}; -const ABOUT: &str = help_about!("shred.md"); -const USAGE: &str = help_usage!("shred.md"); -const AFTER_HELP: &str = help_section!("after help", "shred.md"); +use uucore::locale::{self, get_message}; pub mod options { pub const FORCE: &str = "force"; @@ -316,9 +314,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("shred-about")) + .after_help(get_message("shred-after-help")) + .override_usage(format_usage(&get_message("shred-usage"))) .infer_long_args(true) .arg( Arg::new(options::FORCE) diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 9c08ea28d..73ee2b371 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -30,7 +30,7 @@ enum Mode { } static USAGE: &str = help_usage!("shuf.md"); -static ABOUT: &str = help_about!("shuf.md"); +use uucore::locale::{self, get_message}; struct Options { head_count: usize, @@ -143,9 +143,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about(ABOUT) + .about(get_message("shuf-about")) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) + .override_usage(format_usage(&get_message("shuf-usage"))) .infer_long_args(true) .arg( Arg::new(options::ECHO) diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 2b533eade..ff5b9ae2d 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -15,8 +15,7 @@ use uucore::{ use clap::{Arg, ArgAction, Command}; -static ABOUT: &str = help_about!("sleep.md"); -const USAGE: &str = help_usage!("sleep.md"); +use uucore::locale::{self, get_message}; static AFTER_HELP: &str = help_section!("after help", "sleep.md"); mod options { @@ -47,9 +46,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("sleep-about")) + .after_help(get_message("sleep-after-help")) + .override_usage(format_usage(&get_message("sleep-usage"))) .infer_long_args(true) .arg( Arg::new(options::NUMBER) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 7de7eb1ed..06ae5770d 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -52,9 +52,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_error}; use crate::tmp_dir::TmpDirWrapper; -const ABOUT: &str = help_about!("sort.md"); -const USAGE: &str = help_usage!("sort.md"); -const AFTER_HELP: &str = help_section!("after help", "sort.md"); +use uucore::locale::{self, get_message}; mod options { pub mod modes { @@ -1340,9 +1338,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("sort-about")) + .after_help(get_message("sort-after-help")) + .override_usage(format_usage(&get_message("sort-usage"))) .infer_long_args(true) .disable_help_flag(true) .disable_version_flag(true) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 64548ea38..777cc2479 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -46,9 +46,7 @@ static OPT_IO_BLKSIZE: &str = "-io-blksize"; static ARG_INPUT: &str = "input"; static ARG_PREFIX: &str = "prefix"; -const ABOUT: &str = help_about!("split.md"); -const USAGE: &str = help_usage!("split.md"); -const AFTER_HELP: &str = help_section!("after help", "split.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -229,9 +227,9 @@ fn handle_preceding_options( pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(AFTER_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("split-about")) + .after_help(get_message("split-after-help")) + .override_usage(format_usage(&get_message("split-usage"))) .infer_long_args(true) // strategy (mutually exclusive) .arg( diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 16a96c380..ca82955b6 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -28,8 +28,7 @@ use std::os::unix::prelude::OsStrExt; use std::path::Path; use std::{env, fs}; -const ABOUT: &str = help_about!("stat.md"); -const USAGE: &str = help_usage!("stat.md"); +use uucore::locale::{self, get_message}; const LONG_USAGE: &str = help_section!("long usage", "stat.md"); mod options { @@ -1149,8 +1148,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("stat-about")) + .override_usage(format_usage(&get_message("stat-usage"))) .infer_long_args(true) .arg( Arg::new(options::DEREFERENCE) diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index fa6b2e630..644a5f2ce 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -14,11 +14,11 @@ use std::process; use tempfile::TempDir; use tempfile::tempdir; use uucore::error::{FromIo, UClapError, UResult, USimpleError, UUsageError}; +use uucore::format_usage; use uucore::parser::parse_size::parse_size_u64; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("stdbuf.md"); -const USAGE: &str = help_usage!("stdbuf.md"); +use uucore::locale::{self, get_message}; const LONG_HELP: &str = help_section!("after help", "stdbuf.md"); mod options { @@ -204,9 +204,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(LONG_HELP) - .override_usage(format_usage(USAGE)) + .about(get_message("stdbuf-about")) + .after_help(get_message("stdbuf-after-help")) + .override_usage(format_usage(&get_message("stdbuf-usage"))) .trailing_var_arg(true) .infer_long_args(true) .arg( diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index 4e2ceaa3f..e60e48cb2 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -21,6 +21,7 @@ use std::os::fd::{AsFd, BorrowedFd}; use std::os::unix::fs::OpenOptionsExt; use std::os::unix::io::{AsRawFd, RawFd}; use uucore::error::{UResult, USimpleError}; +use uucore::locale::get_message; use uucore::{format_usage, help_about, help_usage}; #[cfg(not(any( @@ -34,9 +35,6 @@ use uucore::{format_usage, help_about, help_usage}; use flags::BAUD_RATES; use flags::{CONTROL_CHARS, CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS}; -const USAGE: &str = help_usage!("stty.md"); -const SUMMARY: &str = help_about!("stty.md"); - #[derive(Clone, Copy, Debug)] pub struct Flag { name: &'static str, @@ -476,8 +474,8 @@ fn apply_baud_rate_flag(termios: &mut Termios, input: &str) -> ControlFlow pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(SUMMARY) + .override_usage(format_usage(&get_message("stty-usage"))) + .about(get_message("stty-about")) .infer_long_args(true) .arg( Arg::new(options::ALL) diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index 1aec0ef98..57bdbccc6 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -13,8 +13,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; use uucore::{format_usage, help_about, help_usage, show}; -const USAGE: &str = help_usage!("sum.md"); -const ABOUT: &str = help_about!("sum.md"); +use uucore::locale::{self, get_message}; fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> { let mut buf = [0; 4096]; @@ -138,8 +137,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("sum-usage"))) + .about(get_message("sum-about")) .infer_long_args(true) .arg( Arg::new(options::FILE) diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index b0221d3d7..0f45a74a1 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -19,8 +19,7 @@ use uucore::error::FromIo; use uucore::error::{UResult, USimpleError}; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("sync.md"); -const USAGE: &str = help_usage!("sync.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static FILE_SYSTEM: &str = "file-system"; @@ -222,8 +221,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("sync-about")) + .override_usage(format_usage(&get_message("sync-usage"))) .infer_long_args(true) .arg( Arg::new(options::FILE_SYSTEM) diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 4496c2ce1..bcad03b13 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -22,7 +22,7 @@ use uucore::{format_usage, help_about, help_usage, show}; use crate::error::TacError; static USAGE: &str = help_usage!("tac.md"); -static ABOUT: &str = help_about!("tac.md"); +use uucore::locale::{self, get_message}; mod options { pub static BEFORE: &str = "before"; @@ -58,8 +58,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("tac-usage"))) + .about(get_message("tac-about")) .infer_long_args(true) .arg( Arg::new(options::BEFORE) diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 61448388c..329f5c58d 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -18,8 +18,7 @@ use uucore::parser::parse_time; use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::{format_usage, help_about, help_usage, show_warning}; -const ABOUT: &str = help_about!("tail.md"); -const USAGE: &str = help_usage!("tail.md"); +use uucore::locale::{self, get_message}; pub mod options { pub mod verbosity { @@ -464,8 +463,8 @@ pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("tail-about")) + .override_usage(format_usage(&get_message("tail-usage"))) .infer_long_args(true) .arg( Arg::new(options::BYTES) diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index b16caeb93..e366e1474 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -19,9 +19,7 @@ use uucore::{format_usage, help_about, help_section, help_usage, show_error}; #[cfg(unix)] use uucore::signals::{enable_pipe_errors, ignore_interrupts}; -const ABOUT: &str = help_about!("tee.md"); -const USAGE: &str = help_usage!("tee.md"); -const AFTER_HELP: &str = help_section!("after help", "tee.md"); +use uucore::locale::{self, get_message}; mod options { pub const APPEND: &str = "append"; @@ -97,9 +95,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("tee-about")) + .override_usage(format_usage(&get_message("tee-usage"))) + .after_help(get_message("tee-after-help")) .infer_long_args(true) // Since we use value-specific help texts for "--output-error", clap's "short help" and "long help" differ. // However, this is something that the GNU tests explicitly test for, so we *always* show the long help instead. diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index e71e7b191..16c179bcf 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -21,31 +21,23 @@ use uucore::error::{UResult, USimpleError}; use uucore::process::{getegid, geteuid}; use uucore::{format_usage, help_about, help_section}; -const ABOUT: &str = help_about!("test.md"); +use uucore::locale::{self, get_message}; // The help_usage method replaces util name (the first word) with {}. // And, The format_usage method replaces {} with execution_phrase ( e.g. test or [ ). // However, This test command has two util names. // So, we use test or [ instead of {} so that the usage string is correct. -const USAGE: &str = "\ -test EXPRESSION -[ -[ EXPRESSION ] -[ ] -[ OPTION -]"; // We use after_help so that this comes after the usage string (it would come before if we used about) -const AFTER_HELP: &str = help_section!("after help", "test.md"); pub fn uu_app() -> Command { // Disable printing of -h and -v as valid alternatives for --help and --version, // since we don't recognize -h and -v as help/version flags. Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .after_help(AFTER_HELP) + .about(get_message("test-about")) + .override_usage(format_usage(&get_message("test-usage"))) + .after_help(get_message("test-after-help")) } #[uucore::main] diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 9de335801..f7ab93725 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -25,8 +25,7 @@ use uucore::{ signals::{signal_by_name_or_value, signal_name_by_value}, }; -const ABOUT: &str = help_about!("timeout.md"); -const USAGE: &str = help_usage!("timeout.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static FOREGROUND: &str = "foreground"; @@ -122,8 +121,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new("timeout") .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("timeout-about")) + .override_usage(format_usage(&get_message("timeout-usage"))) .arg( Arg::new(options::FOREGROUND) .long(options::FOREGROUND) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 6749933f0..22f546496 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -83,8 +83,7 @@ pub enum Source { Now, } -const ABOUT: &str = help_about!("touch.md"); -const USAGE: &str = help_usage!("touch.md"); +use uucore::locale::{self, get_message}; pub mod options { // Both SOURCES and sources are needed as we need to be able to refer to the ArgGroup. @@ -258,8 +257,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("touch-about")) + .override_usage(format_usage(&get_message("touch-usage"))) .infer_long_args(true) .disable_help_flag(true) .arg( diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index 10a636fd7..3e3cc61cb 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -20,9 +20,7 @@ use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::fs::is_stdin_directory; use uucore::{format_usage, help_about, help_section, help_usage, os_str_as_bytes, show}; -const ABOUT: &str = help_about!("tr.md"); -const AFTER_HELP: &str = help_section!("after help", "tr.md"); -const USAGE: &str = help_usage!("tr.md"); +use uucore::locale::{self, get_message}; mod options { pub const COMPLEMENT: &str = "complement"; @@ -34,7 +32,9 @@ mod options { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; + let matches = uu_app() + .after_help(get_message("tr-after-help")) + .try_get_matches_from(args)?; let delete_flag = matches.get_flag(options::DELETE); let complement_flag = matches.get_flag(options::COMPLEMENT); @@ -164,8 +164,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("tr-about")) + .override_usage(format_usage(&get_message("tr-usage"))) .infer_long_args(true) .trailing_var_arg(true) .arg( diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 29dae0ba6..89a302a45 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -7,7 +7,7 @@ use std::{ffi::OsString, io::Write}; use uucore::error::{UResult, set_exit_code}; use uucore::help_about; -const ABOUT: &str = help_about!("true.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -43,7 +43,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) + .about(get_message("true-about")) // We provide our own help and version options, to ensure maximum compatibility with GNU. .disable_help_flag(true) .disable_version_flag(true) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 056163fa3..ccf9c642e 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -71,9 +71,7 @@ impl TruncateMode { } } -const ABOUT: &str = help_about!("truncate.md"); -const AFTER_HELP: &str = help_section!("after help", "truncate.md"); -const USAGE: &str = help_usage!("truncate.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static IO_BLOCKS: &str = "io-blocks"; @@ -86,7 +84,7 @@ pub mod options { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app() - .after_help(AFTER_HELP) + .after_help(get_message("truncate-after-help")) .try_get_matches_from(args) .map_err(|e| { e.print().expect("Error writing clap::Error"); @@ -117,8 +115,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("truncate-about")) + .override_usage(format_usage(&get_message("truncate-usage"))) .infer_long_args(true) .arg( Arg::new(options::IO_BLOCKS) diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index 3f7e89e99..ce8ee050f 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -11,8 +11,7 @@ use uucore::display::Quotable; use uucore::error::{UError, UResult}; use uucore::{format_usage, help_about, help_usage, show}; -const ABOUT: &str = help_about!("tsort.md"); -const USAGE: &str = help_usage!("tsort.md"); +use uucore::locale::{self, get_message}; mod options { pub const FILE: &str = "file"; @@ -76,8 +75,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("tsort-usage"))) + .about(get_message("tsort-about")) .infer_long_args(true) .arg( Arg::new(options::FILE) diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 35dc1f086..1673ba389 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -12,8 +12,7 @@ use std::io::{IsTerminal, Write}; use uucore::error::{UResult, set_exit_code}; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("tty.md"); -const USAGE: &str = help_usage!("tty.md"); +use uucore::locale::{self, get_message}; mod options { pub const SILENT: &str = "silent"; @@ -58,8 +57,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("tty-about")) + .override_usage(format_usage(&get_message("tty-usage"))) .infer_long_args(true) .arg( Arg::new(options::SILENT) diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index 2e2b5f42f..7c43049e7 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -12,8 +12,7 @@ use uucore::{ format_usage, help_about, help_usage, }; -const ABOUT: &str = help_about!("uname.md"); -const USAGE: &str = help_usage!("uname.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static ALL: &str = "all"; @@ -146,8 +145,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("uname-about")) + .override_usage(format_usage(&get_message("uname-usage"))) .infer_long_args(true) .arg( Arg::new(options::ALL) diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index fb17b971d..12ea29d84 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -17,8 +17,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError}; use uucore::{format_usage, help_about, help_usage, show}; -const USAGE: &str = help_usage!("unexpand.md"); -const ABOUT: &str = help_about!("unexpand.md"); +use uucore::locale::{self, get_message}; const DEFAULT_TABSTOP: usize = 8; @@ -157,8 +156,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .override_usage(format_usage(USAGE)) - .about(ABOUT) + .override_usage(format_usage(&get_message("unexpand-usage"))) + .about(get_message("unexpand-about")) .infer_long_args(true) .arg( Arg::new(options::FILE) diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 2d54a5082..9147b3392 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -17,9 +17,7 @@ use uucore::parser::shortcut_value_parser::ShortcutValueParser; use uucore::posix::{OBSOLETE, posix_version}; use uucore::{format_usage, help_about, help_section, help_usage}; -const ABOUT: &str = help_about!("uniq.md"); -const USAGE: &str = help_usage!("uniq.md"); -const AFTER_HELP: &str = help_section!("after help", "uniq.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static ALL_REPEATED: &str = "all-repeated"; @@ -593,10 +591,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("uniq-about")) + .override_usage(format_usage(&get_message("uniq-usage"))) .infer_long_args(true) - .after_help(AFTER_HELP) + .after_help(get_message("uniq-after-help")) .arg( Arg::new(options::ALL_REPEATED) .short('D') diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 09a1b0f12..311a8482b 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -14,8 +14,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("unlink.md"); -const USAGE: &str = help_usage!("unlink.md"); +use uucore::locale::{self, get_message}; static OPT_PATH: &str = "FILE"; #[uucore::main] @@ -30,8 +29,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("unlink-about")) + .override_usage(format_usage(&get_message("unlink-usage"))) .infer_long_args(true) .arg( Arg::new(OPT_PATH) diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index e001a64a8..25743af78 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -31,9 +31,7 @@ const ABOUT: &str = concat!( ); #[cfg(not(target_env = "musl"))] -const ABOUT: &str = help_about!("uptime.md"); - -const USAGE: &str = help_usage!("uptime.md"); +use uucore::locale::{self, get_message}; pub mod options { pub static SINCE: &str = "since"; @@ -78,8 +76,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { let cmd = Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("uptime-about")) + .override_usage(format_usage(&get_message("uptime-usage"))) .infer_long_args(true) .arg( Arg::new(options::SINCE) diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 192ed0b57..ff0f4190e 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -26,9 +26,7 @@ const ABOUT: &str = concat!( ); #[cfg(not(target_env = "musl"))] -const ABOUT: &str = help_about!("users.md"); - -const USAGE: &str = help_usage!("users.md"); +use uucore::locale::{self, get_message}; #[cfg(target_os = "openbsd")] const OPENBSD_UTMP_FILE: &str = "/var/run/utmp"; @@ -97,8 +95,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("users-about")) + .override_usage(format_usage(&get_message("users-usage"))) .infer_long_args(true) .arg( Arg::new(ARG_FILE) diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 47abfe210..f10c74d82 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -113,8 +113,7 @@ impl<'a> Settings<'a> { } } -const ABOUT: &str = help_about!("wc.md"); -const USAGE: &str = help_usage!("wc.md"); +use uucore::locale::{self, get_message}; mod options { pub static BYTES: &str = "bytes"; @@ -397,8 +396,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("wc-about")) + .override_usage(format_usage(&get_message("wc-usage"))) .infer_long_args(true) .args_override_self(true) .arg( diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 2203bbbd1..9fb6d1c19 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -37,9 +37,7 @@ const ABOUT: &str = concat!( ); #[cfg(not(target_env = "musl"))] -const ABOUT: &str = help_about!("who.md"); - -const USAGE: &str = help_usage!("who.md"); +use uucore::locale::{self, get_message}; #[cfg(target_os = "linux")] static RUNLEVEL_HELP: &str = "print current runlevel"; @@ -52,8 +50,8 @@ use platform::uumain; pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("who-about")) + .override_usage(format_usage(&get_message("who-usage"))) .infer_long_args(true) .arg( Arg::new(options::ALL) diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index a1fe6e622..4e1cc795c 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -13,8 +13,7 @@ use uucore::{format_usage, help_about, help_usage}; mod platform; -const ABOUT: &str = help_about!("whoami.md"); -const USAGE: &str = help_usage!("whoami.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -32,7 +31,7 @@ pub fn whoami() -> UResult { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("whoami-about")) + .override_usage(uucore::util_name()) .infer_long_args(true) } diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index df77be289..33e922c76 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -14,8 +14,7 @@ use uucore::error::{UResult, USimpleError}; use uucore::signals::enable_pipe_errors; use uucore::{format_usage, help_about, help_usage}; -const ABOUT: &str = help_about!("yes.md"); -const USAGE: &str = help_usage!("yes.md"); +use uucore::locale::{self, get_message}; // it's possible that using a smaller or larger buffer might provide better performance on some // systems, but honestly this is good enough @@ -39,8 +38,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) + .about(get_message("yes-about")) + .override_usage(format_usage(&get_message("yes-usage"))) .arg( Arg::new("STRING") .value_parser(ValueParser::os_string())