mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
use the new translate! macro for translation
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
co-authored by
Daniel Hofstetter
parent
bd005d12b9
commit
862a7a705c
Generated
+100
File diff suppressed because it is too large
Load Diff
Generated
+13
@@ -1435,6 +1435,7 @@ name = "uu_cksum"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"hex",
|
||||
"uucore",
|
||||
]
|
||||
@@ -1445,6 +1446,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"clap",
|
||||
"fluent",
|
||||
"memchr",
|
||||
"uucore",
|
||||
]
|
||||
@@ -1455,6 +1457,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"fluent",
|
||||
"jiff",
|
||||
"libc",
|
||||
"parse_datetime",
|
||||
@@ -1467,6 +1470,7 @@ name = "uu_echo"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -1475,6 +1479,7 @@ name = "uu_env"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"nix",
|
||||
"rust-ini",
|
||||
"thiserror",
|
||||
@@ -1486,6 +1491,7 @@ name = "uu_expr"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"onig",
|
||||
@@ -1498,6 +1504,7 @@ name = "uu_printf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -1507,6 +1514,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bigdecimal",
|
||||
"clap",
|
||||
"fluent",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"thiserror",
|
||||
@@ -1522,6 +1530,7 @@ dependencies = [
|
||||
"clap",
|
||||
"compare",
|
||||
"ctrlc",
|
||||
"fluent",
|
||||
"fnv",
|
||||
"itertools",
|
||||
"memchr",
|
||||
@@ -1540,6 +1549,7 @@ name = "uu_split"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"memchr",
|
||||
"thiserror",
|
||||
"uucore",
|
||||
@@ -1550,6 +1560,7 @@ name = "uu_test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"libc",
|
||||
"thiserror",
|
||||
"uucore",
|
||||
@@ -1560,6 +1571,7 @@ name = "uu_tr"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"nom",
|
||||
"uucore",
|
||||
]
|
||||
@@ -1570,6 +1582,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"clap",
|
||||
"fluent",
|
||||
"libc",
|
||||
"nix",
|
||||
"thiserror",
|
||||
|
||||
@@ -21,6 +21,7 @@ path = "src/arch.rs"
|
||||
platform-info = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "arch"
|
||||
|
||||
@@ -7,14 +7,14 @@ use platform_info::*;
|
||||
|
||||
use clap::Command;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::locale::get_message;
|
||||
use uucore::translate;
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let uts =
|
||||
PlatformInfo::new().map_err(|_e| USimpleError::new(1, get_message("cannot-get-system")))?;
|
||||
PlatformInfo::new().map_err(|_e| USimpleError::new(1, translate!("cannot-get-system")))?;
|
||||
|
||||
println!("{}", uts.machine().to_string_lossy().trim());
|
||||
Ok(())
|
||||
@@ -23,7 +23,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(uucore::crate_version!())
|
||||
.about(get_message("arch-about"))
|
||||
.after_help(get_message("arch-after-help"))
|
||||
.about(translate!("arch-about"))
|
||||
.after_help(translate!("arch-after-help"))
|
||||
.infer_long_args(true)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ path = "src/base32.rs"
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true, features = ["encoding"] }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "base32"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
pub mod base_common;
|
||||
|
||||
use clap::Command;
|
||||
use uucore::{encoding::Format, error::UResult, locale::get_message};
|
||||
use uucore::{encoding::Format, error::UResult, translate};
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
@@ -23,7 +23,7 @@ pub fn uu_app() -> Command {
|
||||
}
|
||||
|
||||
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());
|
||||
let about: &'static str = Box::leak(translate!("base32-about").into_boxed_str());
|
||||
let usage: &'static str = Box::leak(translate!("base32-usage").into_boxed_str());
|
||||
(about, usage)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
// spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -18,7 +17,7 @@ use uucore::encoding::{
|
||||
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
use uucore::translate;
|
||||
|
||||
pub const BASE_CMD_PARSE_ERROR: i32 = 1;
|
||||
|
||||
@@ -52,10 +51,7 @@ impl Config {
|
||||
if let Some(extra_op) = values.next() {
|
||||
return Err(UUsageError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
get_message_with_args(
|
||||
"base-common-extra-operand",
|
||||
HashMap::from([("operand".to_string(), extra_op.quote().to_string())]),
|
||||
),
|
||||
translate!("base-common-extra-operand", "operand" => extra_op.quote()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -67,13 +63,7 @@ impl Config {
|
||||
if !path.exists() {
|
||||
return Err(USimpleError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
get_message_with_args(
|
||||
"base-common-no-such-file",
|
||||
HashMap::from([(
|
||||
"file".to_string(),
|
||||
path.maybe_quote().to_string(),
|
||||
)]),
|
||||
),
|
||||
translate!("base-common-no-such-file", "file" => path.maybe_quote()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -89,10 +79,7 @@ impl Config {
|
||||
num.parse::<usize>().map_err(|_| {
|
||||
USimpleError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
get_message_with_args(
|
||||
"base-common-invalid-wrap-size",
|
||||
HashMap::from([("size".to_string(), num.quote().to_string())]),
|
||||
),
|
||||
translate!("base-common-invalid-wrap-size", "size" => num.quote()),
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -128,7 +115,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
|
||||
.short('d')
|
||||
.visible_short_alias('D')
|
||||
.long(options::DECODE)
|
||||
.help(get_message("base-common-help-decode"))
|
||||
.help(translate!("base-common-help-decode"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::DECODE),
|
||||
)
|
||||
@@ -136,7 +123,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
|
||||
Arg::new(options::IGNORE_GARBAGE)
|
||||
.short('i')
|
||||
.long(options::IGNORE_GARBAGE)
|
||||
.help(get_message("base-common-help-ignore-garbage"))
|
||||
.help(translate!("base-common-help-ignore-garbage"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::IGNORE_GARBAGE),
|
||||
)
|
||||
@@ -145,10 +132,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
|
||||
.short('w')
|
||||
.long(options::WRAP)
|
||||
.value_name("COLS")
|
||||
.help(get_message_with_args(
|
||||
"base-common-help-wrap",
|
||||
HashMap::from([("default".to_string(), WRAP_DEFAULT.to_string())]),
|
||||
))
|
||||
.help(translate!("base-common-help-wrap", "default" => WRAP_DEFAULT))
|
||||
.overrides_with(options::WRAP),
|
||||
)
|
||||
// "multiple" arguments are used to check whether there is more than one
|
||||
@@ -830,10 +814,7 @@ fn format_read_error(kind: ErrorKind) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
get_message_with_args(
|
||||
"base-common-read-error",
|
||||
HashMap::from([("error".to_string(), kind_string_capitalized)]),
|
||||
)
|
||||
translate!("base-common-read-error", "error" => kind_string_capitalized)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -21,6 +21,7 @@ path = "src/base64.rs"
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true, features = ["encoding"] }
|
||||
uu_base32 = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "base64"
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
use clap::Command;
|
||||
use uu_base32::base_common;
|
||||
use uucore::{encoding::Format, error::UResult, locale::get_message};
|
||||
use uucore::translate;
|
||||
use uucore::{encoding::Format, error::UResult};
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
@@ -22,7 +23,7 @@ pub fn uu_app() -> Command {
|
||||
}
|
||||
|
||||
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());
|
||||
let about: &'static str = Box::leak(translate!("base64-about").into_boxed_str());
|
||||
let usage: &'static str = Box::leak(translate!("base64-usage").into_boxed_str());
|
||||
(about, usage)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ path = "src/basename.rs"
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "basename"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use std::io::{Write, stdout};
|
||||
use std::path::PathBuf;
|
||||
@@ -16,7 +15,7 @@ use uucore::error::{UResult, UUsageError};
|
||||
use uucore::format_usage;
|
||||
use uucore::line_ending::LineEnding;
|
||||
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
use uucore::translate;
|
||||
|
||||
pub mod options {
|
||||
pub static MULTIPLE: &str = "multiple";
|
||||
@@ -41,7 +40,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
if name_args.is_empty() {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
get_message("basename-error-missing-operand"),
|
||||
translate!("basename-error-missing-operand"),
|
||||
));
|
||||
}
|
||||
let multiple_paths = matches.get_one::<OsString>(options::SUFFIX).is_some()
|
||||
@@ -60,10 +59,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
_ => {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
get_message_with_args(
|
||||
"basename-error-extra-operand",
|
||||
HashMap::from([("operand".to_string(), name_args[2].quote().to_string())]),
|
||||
),
|
||||
translate!("basename-error-extra-operand",
|
||||
"operand" => name_args[2].quote()),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -84,14 +81,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(uucore::crate_version!())
|
||||
.about(get_message("basename-about"))
|
||||
.override_usage(format_usage(&get_message("basename-usage")))
|
||||
.about(translate!("basename-about"))
|
||||
.override_usage(format_usage(&translate!("basename-usage")))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::MULTIPLE)
|
||||
.short('a')
|
||||
.long(options::MULTIPLE)
|
||||
.help(get_message("basename-help-multiple"))
|
||||
.help(translate!("basename-help-multiple"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::MULTIPLE),
|
||||
)
|
||||
@@ -109,14 +106,14 @@ pub fn uu_app() -> Command {
|
||||
.long(options::SUFFIX)
|
||||
.value_name("SUFFIX")
|
||||
.value_parser(ValueParser::os_string())
|
||||
.help(get_message("basename-help-suffix"))
|
||||
.help(translate!("basename-help-suffix"))
|
||||
.overrides_with(options::SUFFIX),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ZERO)
|
||||
.short('z')
|
||||
.long(options::ZERO)
|
||||
.help(get_message("basename-help-zero"))
|
||||
.help(translate!("basename-help-zero"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::ZERO),
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ path = "src/basenc.rs"
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true, features = ["encoding"] }
|
||||
uu_base32 = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "basenc"
|
||||
|
||||
+12
-12
@@ -8,7 +8,7 @@
|
||||
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::translate;
|
||||
use uucore::{
|
||||
encoding::Format,
|
||||
error::{UResult, UUsageError},
|
||||
@@ -16,36 +16,36 @@ use uucore::{
|
||||
|
||||
fn get_encodings() -> Vec<(&'static str, Format, String)> {
|
||||
vec![
|
||||
("base64", Format::Base64, get_message("basenc-help-base64")),
|
||||
("base64", Format::Base64, translate!("basenc-help-base64")),
|
||||
(
|
||||
"base64url",
|
||||
Format::Base64Url,
|
||||
get_message("basenc-help-base64url"),
|
||||
translate!("basenc-help-base64url"),
|
||||
),
|
||||
("base32", Format::Base32, get_message("basenc-help-base32")),
|
||||
("base32", Format::Base32, translate!("basenc-help-base32")),
|
||||
(
|
||||
"base32hex",
|
||||
Format::Base32Hex,
|
||||
get_message("basenc-help-base32hex"),
|
||||
translate!("basenc-help-base32hex"),
|
||||
),
|
||||
("base16", Format::Base16, get_message("basenc-help-base16")),
|
||||
("base16", Format::Base16, translate!("basenc-help-base16")),
|
||||
(
|
||||
"base2lsbf",
|
||||
Format::Base2Lsbf,
|
||||
get_message("basenc-help-base2lsbf"),
|
||||
translate!("basenc-help-base2lsbf"),
|
||||
),
|
||||
(
|
||||
"base2msbf",
|
||||
Format::Base2Msbf,
|
||||
get_message("basenc-help-base2msbf"),
|
||||
translate!("basenc-help-base2msbf"),
|
||||
),
|
||||
("z85", Format::Z85, get_message("basenc-help-z85")),
|
||||
("z85", Format::Z85, translate!("basenc-help-z85")),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn uu_app() -> Command {
|
||||
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 about: &'static str = Box::leak(translate!("basenc-about").into_boxed_str());
|
||||
let usage: &'static str = Box::leak(translate!("basenc-usage").into_boxed_str());
|
||||
|
||||
let encodings = get_encodings();
|
||||
let mut command = base_common::base_app(about, usage);
|
||||
@@ -75,7 +75,7 @@ fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
|
||||
.ok_or_else(|| {
|
||||
UUsageError::new(
|
||||
BASE_CMD_PARSE_ERROR,
|
||||
get_message("basenc-error-missing-encoding-type"),
|
||||
translate!("basenc-error-missing-encoding-type"),
|
||||
)
|
||||
})?
|
||||
.1;
|
||||
|
||||
@@ -22,6 +22,7 @@ clap = { workspace = true }
|
||||
memchr = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
uucore = { workspace = true, features = ["fast-inc", "fs", "pipes"] }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = { workspace = true }
|
||||
|
||||
@@ -26,7 +26,7 @@ use uucore::display::Quotable;
|
||||
use uucore::error::UResult;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use uucore::libc;
|
||||
use uucore::locale::get_message;
|
||||
use uucore::translate;
|
||||
use uucore::{fast_inc::fast_inc_one, format_usage};
|
||||
|
||||
/// Linux splice support
|
||||
@@ -284,8 +284,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(&get_message("cat-usage")))
|
||||
.about(get_message("cat-about"))
|
||||
.override_usage(format_usage(&translate!("cat-usage")))
|
||||
.about(translate!("cat-about"))
|
||||
.infer_long_args(true)
|
||||
.args_override_self(true)
|
||||
.arg(
|
||||
|
||||
@@ -24,6 +24,7 @@ selinux = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
fts-sys = { workspace = true }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "chcon"
|
||||
|
||||
+51
-90
@@ -8,13 +8,13 @@
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use uucore::error::{UResult, USimpleError, UUsageError};
|
||||
use uucore::translate;
|
||||
use uucore::{display::Quotable, format_usage, show_error, show_warning};
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use selinux::{OpaqueSecurityContext, SecurityContext};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::{CStr, CString, OsStr, OsString};
|
||||
use std::os::raw::c_int;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -25,8 +25,6 @@ mod fts;
|
||||
|
||||
use errors::*;
|
||||
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
|
||||
pub mod options {
|
||||
pub static HELP: &str = "help";
|
||||
pub static VERBOSE: &str = "verbose";
|
||||
@@ -80,14 +78,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
Ok(None) => {
|
||||
let err = io::Error::from_raw_os_error(libc::ENODATA);
|
||||
Err(Error::from_io1(
|
||||
get_message("chcon-op-getting-security-context"),
|
||||
translate!("chcon-op-getting-security-context"),
|
||||
reference,
|
||||
err,
|
||||
))
|
||||
}
|
||||
|
||||
Err(r) => Err(Error::from_selinux(
|
||||
get_message("chcon-op-getting-security-context"),
|
||||
translate!("chcon-op-getting-security-context"),
|
||||
r,
|
||||
)),
|
||||
};
|
||||
@@ -111,10 +109,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
Err(_r) => {
|
||||
return Err(USimpleError::new(
|
||||
libc::EXIT_FAILURE,
|
||||
get_message_with_args(
|
||||
"chcon-error-invalid-context",
|
||||
HashMap::from([("context".to_string(), context.quote().to_string())]),
|
||||
),
|
||||
translate!("chcon-error-invalid-context", "context" => context.quote()),
|
||||
));
|
||||
}
|
||||
};
|
||||
@@ -122,10 +117,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
if SecurityContext::from_c_str(&c_context, false).check() == Some(false) {
|
||||
return Err(USimpleError::new(
|
||||
libc::EXIT_FAILURE,
|
||||
get_message_with_args(
|
||||
"chcon-error-invalid-context",
|
||||
HashMap::from([("context".to_string(), context.quote().to_string())]),
|
||||
),
|
||||
translate!("chcon-error-invalid-context", "context" => context.quote()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -164,42 +156,42 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(uucore::crate_version!())
|
||||
.about(get_message("chcon-about"))
|
||||
.override_usage(format_usage(&get_message("chcon-usage")))
|
||||
.about(translate!("chcon-about"))
|
||||
.override_usage(format_usage(&translate!("chcon-usage")))
|
||||
.infer_long_args(true)
|
||||
.disable_help_flag(true)
|
||||
.args_override_self(true)
|
||||
.arg(
|
||||
Arg::new(options::HELP)
|
||||
.long(options::HELP)
|
||||
.help(get_message("chcon-help-help"))
|
||||
.help(translate!("chcon-help-help"))
|
||||
.action(ArgAction::Help),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::dereference::DEREFERENCE)
|
||||
.long(options::dereference::DEREFERENCE)
|
||||
.overrides_with(options::dereference::NO_DEREFERENCE)
|
||||
.help(get_message("chcon-help-dereference"))
|
||||
.help(translate!("chcon-help-dereference"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::dereference::NO_DEREFERENCE)
|
||||
.short('h')
|
||||
.long(options::dereference::NO_DEREFERENCE)
|
||||
.help(get_message("chcon-help-no-dereference"))
|
||||
.help(translate!("chcon-help-no-dereference"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::PRESERVE_ROOT)
|
||||
.long(options::preserve_root::PRESERVE_ROOT)
|
||||
.overrides_with(options::preserve_root::NO_PRESERVE_ROOT)
|
||||
.help(get_message("chcon-help-preserve-root"))
|
||||
.help(translate!("chcon-help-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::NO_PRESERVE_ROOT)
|
||||
.long(options::preserve_root::NO_PRESERVE_ROOT)
|
||||
.help(get_message("chcon-help-no-preserve-root"))
|
||||
.help(translate!("chcon-help-no-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -208,7 +200,7 @@ pub fn uu_app() -> Command {
|
||||
.value_name("RFILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.conflicts_with_all([options::USER, options::ROLE, options::TYPE, options::RANGE])
|
||||
.help(get_message("chcon-help-reference"))
|
||||
.help(translate!("chcon-help-reference"))
|
||||
.value_parser(ValueParser::os_string()),
|
||||
)
|
||||
.arg(
|
||||
@@ -217,7 +209,7 @@ pub fn uu_app() -> Command {
|
||||
.long(options::USER)
|
||||
.value_name("USER")
|
||||
.value_hint(clap::ValueHint::Username)
|
||||
.help(get_message("chcon-help-user"))
|
||||
.help(translate!("chcon-help-user"))
|
||||
.value_parser(ValueParser::os_string()),
|
||||
)
|
||||
.arg(
|
||||
@@ -225,7 +217,7 @@ pub fn uu_app() -> Command {
|
||||
.short('r')
|
||||
.long(options::ROLE)
|
||||
.value_name("ROLE")
|
||||
.help(get_message("chcon-help-role"))
|
||||
.help(translate!("chcon-help-role"))
|
||||
.value_parser(ValueParser::os_string()),
|
||||
)
|
||||
.arg(
|
||||
@@ -233,7 +225,7 @@ pub fn uu_app() -> Command {
|
||||
.short('t')
|
||||
.long(options::TYPE)
|
||||
.value_name("TYPE")
|
||||
.help(get_message("chcon-help-type"))
|
||||
.help(translate!("chcon-help-type"))
|
||||
.value_parser(ValueParser::os_string()),
|
||||
)
|
||||
.arg(
|
||||
@@ -241,14 +233,14 @@ pub fn uu_app() -> Command {
|
||||
.short('l')
|
||||
.long(options::RANGE)
|
||||
.value_name("RANGE")
|
||||
.help(get_message("chcon-help-range"))
|
||||
.help(translate!("chcon-help-range"))
|
||||
.value_parser(ValueParser::os_string()),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::RECURSIVE)
|
||||
.short('R')
|
||||
.long(options::RECURSIVE)
|
||||
.help(get_message("chcon-help-recursive"))
|
||||
.help(translate!("chcon-help-recursive"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -259,7 +251,7 @@ pub fn uu_app() -> Command {
|
||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||
options::sym_links::NO_FOLLOW_SYM_LINKS,
|
||||
])
|
||||
.help(get_message("chcon-help-follow-arg-dir-symlink"))
|
||||
.help(translate!("chcon-help-follow-arg-dir-symlink"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -270,7 +262,7 @@ pub fn uu_app() -> Command {
|
||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||
options::sym_links::NO_FOLLOW_SYM_LINKS,
|
||||
])
|
||||
.help(get_message("chcon-help-follow-dir-symlinks"))
|
||||
.help(translate!("chcon-help-follow-dir-symlinks"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -281,14 +273,14 @@ pub fn uu_app() -> Command {
|
||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||
])
|
||||
.help(get_message("chcon-help-no-follow-symlinks"))
|
||||
.help(translate!("chcon-help-no-follow-symlinks"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::VERBOSE)
|
||||
.short('v')
|
||||
.long(options::VERBOSE)
|
||||
.help(get_message("chcon-help-verbose"))
|
||||
.help(translate!("chcon-help-verbose"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -318,24 +310,24 @@ fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Option
|
||||
let (recursive_mode, affect_symlink_referent) = if matches.get_flag(options::RECURSIVE) {
|
||||
if matches.get_flag(options::sym_links::FOLLOW_DIR_SYM_LINKS) {
|
||||
if matches.get_flag(options::dereference::NO_DEREFERENCE) {
|
||||
return Err(Error::ArgumentsMismatch(get_message(
|
||||
"chcon-error-recursive-no-dereference-require-p",
|
||||
return Err(Error::ArgumentsMismatch(translate!(
|
||||
"chcon-error-recursive-no-dereference-require-p"
|
||||
)));
|
||||
}
|
||||
|
||||
(RecursiveMode::RecursiveAndFollowAllDirSymLinks, true)
|
||||
} else if matches.get_flag(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK) {
|
||||
if matches.get_flag(options::dereference::NO_DEREFERENCE) {
|
||||
return Err(Error::ArgumentsMismatch(get_message(
|
||||
"chcon-error-recursive-no-dereference-require-p",
|
||||
return Err(Error::ArgumentsMismatch(translate!(
|
||||
"chcon-error-recursive-no-dereference-require-p"
|
||||
)));
|
||||
}
|
||||
|
||||
(RecursiveMode::RecursiveAndFollowArgDirSymLinks, true)
|
||||
} else {
|
||||
if matches.get_flag(options::dereference::DEREFERENCE) {
|
||||
return Err(Error::ArgumentsMismatch(get_message(
|
||||
"chcon-error-recursive-dereference-require-h-or-l",
|
||||
return Err(Error::ArgumentsMismatch(translate!(
|
||||
"chcon-error-recursive-dereference-require-h-or-l"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -510,7 +502,7 @@ fn process_file(
|
||||
|
||||
let file_full_name = entry.path().map(PathBuf::from).ok_or_else(|| {
|
||||
Error::from_io(
|
||||
get_message("chcon-op-file-name-validation"),
|
||||
translate!("chcon-op-file-name-validation"),
|
||||
io::ErrorKind::InvalidInput.into(),
|
||||
)
|
||||
})?;
|
||||
@@ -518,7 +510,7 @@ fn process_file(
|
||||
let fts_access_path = entry.access_path().ok_or_else(|| {
|
||||
let err = io::ErrorKind::InvalidInput.into();
|
||||
Error::from_io1(
|
||||
get_message("chcon-op-file-name-validation"),
|
||||
translate!("chcon-op-file-name-validation"),
|
||||
&file_full_name,
|
||||
err,
|
||||
)
|
||||
@@ -536,7 +528,7 @@ fn process_file(
|
||||
st.try_into()?
|
||||
} else {
|
||||
return Err(err(
|
||||
get_message("chcon-op-getting-meta-data"),
|
||||
translate!("chcon-op-getting-meta-data"),
|
||||
io::ErrorKind::InvalidInput,
|
||||
));
|
||||
};
|
||||
@@ -558,7 +550,7 @@ fn process_file(
|
||||
let _ignored = fts.read_next_entry();
|
||||
|
||||
return Err(err(
|
||||
get_message("chcon-op-modifying-root-path"),
|
||||
translate!("chcon-op-modifying-root-path"),
|
||||
io::ErrorKind::PermissionDenied,
|
||||
));
|
||||
}
|
||||
@@ -585,18 +577,18 @@ fn process_file(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
result = fts_err(get_message("chcon-op-accessing"));
|
||||
result = fts_err(translate!("chcon-op-accessing"));
|
||||
}
|
||||
|
||||
fts_sys::FTS_ERR => result = fts_err(get_message("chcon-op-accessing")),
|
||||
fts_sys::FTS_ERR => result = fts_err(translate!("chcon-op-accessing")),
|
||||
|
||||
fts_sys::FTS_DNR => result = fts_err(get_message("chcon-op-reading-directory")),
|
||||
fts_sys::FTS_DNR => result = fts_err(translate!("chcon-op-reading-directory")),
|
||||
|
||||
fts_sys::FTS_DC => {
|
||||
if cycle_warning_required(options.recursive_mode.fts_open_options(), &entry) {
|
||||
emit_cycle_warning(&file_full_name);
|
||||
return Err(err(
|
||||
get_message("chcon-op-reading-cyclic-directory"),
|
||||
translate!("chcon-op-reading-cyclic-directory"),
|
||||
io::ErrorKind::InvalidData,
|
||||
));
|
||||
}
|
||||
@@ -611,7 +603,7 @@ fn process_file(
|
||||
{
|
||||
root_dev_ino_warn(&file_full_name);
|
||||
result = Err(err(
|
||||
get_message("chcon-op-modifying-root-path"),
|
||||
translate!("chcon-op-modifying-root-path"),
|
||||
io::ErrorKind::PermissionDenied,
|
||||
));
|
||||
}
|
||||
@@ -620,13 +612,7 @@ fn process_file(
|
||||
if options.verbose {
|
||||
println!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"chcon-verbose-changing-context",
|
||||
HashMap::from([
|
||||
("util_name".to_string(), uucore::util_name().to_string()),
|
||||
("file".to_string(), file_full_name.quote().to_string())
|
||||
])
|
||||
)
|
||||
translate!("chcon-verbose-changing-context", "util_name" => uucore::util_name(), "file" => file_full_name.quote())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -654,7 +640,7 @@ fn change_file_context(
|
||||
let err0 = || -> Result<()> {
|
||||
// If the file doesn't have a context, and we're not setting all of the context
|
||||
// components, there isn't really an obvious default. Thus, we just give up.
|
||||
let op = get_message("chcon-op-applying-partial-context");
|
||||
let op = translate!("chcon-op-applying-partial-context");
|
||||
let err = io::ErrorKind::InvalidInput.into();
|
||||
Err(Error::from_io1(op, path, err))
|
||||
};
|
||||
@@ -666,7 +652,7 @@ fn change_file_context(
|
||||
Ok(None) => return err0(),
|
||||
Err(r) => {
|
||||
return Err(Error::from_selinux(
|
||||
get_message("chcon-op-getting-security-context"),
|
||||
translate!("chcon-op-getting-security-context"),
|
||||
r,
|
||||
));
|
||||
}
|
||||
@@ -678,7 +664,7 @@ fn change_file_context(
|
||||
Ok(None) => return err0(),
|
||||
Err(r) => {
|
||||
return Err(Error::from_selinux(
|
||||
get_message("chcon-op-getting-security-context"),
|
||||
translate!("chcon-op-getting-security-context"),
|
||||
r,
|
||||
));
|
||||
}
|
||||
@@ -687,7 +673,7 @@ fn change_file_context(
|
||||
let se_context =
|
||||
OpaqueSecurityContext::from_c_str(c_file_context.as_ref()).map_err(|_r| {
|
||||
let err = io::ErrorKind::InvalidInput.into();
|
||||
Error::from_io1(get_message("chcon-op-creating-security-context"), path, err)
|
||||
Error::from_io1(translate!("chcon-op-creating-security-context"), path, err)
|
||||
})?;
|
||||
|
||||
type SetValueProc = fn(&OpaqueSecurityContext, &CStr) -> selinux::errors::Result<()>;
|
||||
@@ -703,24 +689,17 @@ fn change_file_context(
|
||||
if let Some(new_value) = new_value {
|
||||
let c_new_value = os_str_to_c_string(new_value).map_err(|_r| {
|
||||
let err = io::ErrorKind::InvalidInput.into();
|
||||
Error::from_io1(
|
||||
get_message("chcon-op-creating-security-context"),
|
||||
path,
|
||||
err,
|
||||
)
|
||||
Error::from_io1(translate!("chcon-op-creating-security-context"), path, err)
|
||||
})?;
|
||||
|
||||
set_value_proc(&se_context, &c_new_value).map_err(|r| {
|
||||
Error::from_selinux(
|
||||
get_message("chcon-op-setting-security-context-user"),
|
||||
r,
|
||||
)
|
||||
Error::from_selinux(translate!("chcon-op-setting-security-context-user"), r)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
let context_string = se_context.to_c_string().map_err(|r| {
|
||||
Error::from_selinux(get_message("chcon-op-getting-security-context"), r)
|
||||
Error::from_selinux(translate!("chcon-op-getting-security-context"), r)
|
||||
})?;
|
||||
|
||||
if c_file_context.as_ref().to_bytes() == context_string.as_ref().to_bytes() {
|
||||
@@ -729,7 +708,7 @@ fn change_file_context(
|
||||
SecurityContext::from_c_str(&context_string, false)
|
||||
.set_for_path(path, options.affect_symlink_referent, false)
|
||||
.map_err(|r| {
|
||||
Error::from_selinux(get_message("chcon-op-setting-security-context"), r)
|
||||
Error::from_selinux(translate!("chcon-op-setting-security-context"), r)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -739,12 +718,12 @@ fn change_file_context(
|
||||
SecurityContext::from_c_str(c_context.as_ref(), false)
|
||||
.set_for_path(path, options.affect_symlink_referent, false)
|
||||
.map_err(|r| {
|
||||
Error::from_selinux(get_message("chcon-op-setting-security-context"), r)
|
||||
Error::from_selinux(translate!("chcon-op-setting-security-context"), r)
|
||||
})
|
||||
} else {
|
||||
let err = io::ErrorKind::InvalidInput.into();
|
||||
Err(Error::from_io1(
|
||||
get_message("chcon-op-setting-security-context"),
|
||||
translate!("chcon-op-setting-security-context"),
|
||||
path,
|
||||
err,
|
||||
))
|
||||
@@ -777,27 +756,12 @@ fn root_dev_ino_warn(dir_name: &Path) {
|
||||
if dir_name.as_os_str() == "/" {
|
||||
show_warning!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"chcon-warning-dangerous-recursive-root",
|
||||
HashMap::from([(
|
||||
"option".to_string(),
|
||||
options::preserve_root::NO_PRESERVE_ROOT.to_string()
|
||||
)])
|
||||
)
|
||||
translate!("chcon-warning-dangerous-recursive-root", "option" => options::preserve_root::NO_PRESERVE_ROOT)
|
||||
);
|
||||
} else {
|
||||
show_warning!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"chcon-warning-dangerous-recursive-dir",
|
||||
HashMap::from([
|
||||
("dir".to_string(), dir_name.to_string_lossy().to_string()),
|
||||
(
|
||||
"option".to_string(),
|
||||
options::preserve_root::NO_PRESERVE_ROOT.to_string()
|
||||
)
|
||||
])
|
||||
)
|
||||
translate!("chcon-warning-dangerous-recursive-dir", "dir" => dir_name.to_string_lossy(), "option" => options::preserve_root::NO_PRESERVE_ROOT)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -819,10 +783,7 @@ fn cycle_warning_required(fts_options: c_int, entry: &fts::EntryRef) -> bool {
|
||||
fn emit_cycle_warning(file_name: &Path) {
|
||||
show_warning!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"chcon-warning-circular-directory",
|
||||
HashMap::from([("file".to_string(), file_name.to_string_lossy().to_string())])
|
||||
)
|
||||
translate!("chcon-warning-circular-directory", "file" => file_name.to_string_lossy())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,26 +4,25 @@
|
||||
// file that was distributed with this source code.
|
||||
#![cfg(target_os = "linux")]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt::Write;
|
||||
use std::io;
|
||||
|
||||
use thiserror::Error;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
use uucore::translate;
|
||||
|
||||
pub(crate) type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Error {
|
||||
#[error("{}", get_message("chcon-error-no-context-specified"))]
|
||||
#[error("{}", translate!("chcon-error-no-context-specified"))]
|
||||
MissingContext,
|
||||
|
||||
#[error("{}", get_message("chcon-error-no-files-specified"))]
|
||||
#[error("{}", translate!("chcon-error-no-files-specified"))]
|
||||
MissingFiles,
|
||||
|
||||
#[error("{}", get_message("chcon-error-data-out-of-range"))]
|
||||
#[error("{}", translate!("chcon-error-data-out-of-range"))]
|
||||
OutOfRange,
|
||||
|
||||
#[error("{0}")]
|
||||
@@ -32,21 +31,21 @@ pub(crate) enum Error {
|
||||
#[error(transparent)]
|
||||
CommandLine(#[from] clap::Error),
|
||||
|
||||
#[error("{}", get_message_with_args("chcon-error-operation-failed", HashMap::from([("operation".to_string(), operation.clone())])))]
|
||||
#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation.clone()))]
|
||||
SELinux {
|
||||
operation: String,
|
||||
#[source]
|
||||
source: selinux::errors::Error,
|
||||
},
|
||||
|
||||
#[error("{}", get_message_with_args("chcon-error-operation-failed", HashMap::from([("operation".to_string(), operation.clone())])))]
|
||||
#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation.clone()))]
|
||||
Io {
|
||||
operation: String,
|
||||
#[source]
|
||||
source: io::Error,
|
||||
},
|
||||
|
||||
#[error("{}", get_message_with_args("chcon-error-operation-failed-on", HashMap::from([("operation".to_string(), operation.clone()), ("operand".to_string(), operand1.quote().to_string())])))]
|
||||
#[error("{}", translate!("chcon-error-operation-failed-on", "operation" => operation.clone(), "operand" => operand1.quote()))]
|
||||
Io1 {
|
||||
operation: String,
|
||||
operand1: OsString,
|
||||
|
||||
@@ -20,6 +20,7 @@ path = "src/chgrp.rs"
|
||||
[dependencies]
|
||||
clap = { workspace = true }
|
||||
uucore = { workspace = true, features = ["entries", "fs", "perms"] }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "chgrp"
|
||||
|
||||
+22
-36
@@ -10,35 +10,27 @@ pub use uucore::entries;
|
||||
use uucore::error::{FromIo, UResult, USimpleError};
|
||||
use uucore::format_usage;
|
||||
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
|
||||
use uucore::translate;
|
||||
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use std::fs;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
|
||||
fn parse_gid_from_str(group: &str) -> Result<u32, String> {
|
||||
if let Some(gid_str) = group.strip_prefix(':') {
|
||||
// Handle :gid format
|
||||
gid_str.parse::<u32>().map_err(|_| {
|
||||
get_message_with_args(
|
||||
"chgrp-error-invalid-group-id",
|
||||
HashMap::from([("gid_str".to_string(), gid_str.to_string())]),
|
||||
)
|
||||
})
|
||||
gid_str
|
||||
.parse::<u32>()
|
||||
.map_err(|_| translate!("chgrp-error-invalid-group-id", "gid_str" => gid_str))
|
||||
} else {
|
||||
// Try as group name first
|
||||
match entries::grp2gid(group) {
|
||||
Ok(g) => Ok(g),
|
||||
// If group name lookup fails, try parsing as raw number
|
||||
Err(_) => group.parse::<u32>().map_err(|_| {
|
||||
get_message_with_args(
|
||||
"chgrp-error-invalid-group",
|
||||
HashMap::from([("group".to_string(), group.to_string())]),
|
||||
)
|
||||
}),
|
||||
Err(_) => group
|
||||
.parse::<u32>()
|
||||
.map_err(|_| translate!("chgrp-error-invalid-group", "group" => group)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,12 +44,9 @@ fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option<u32>, String)> {
|
||||
raw_group = entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string());
|
||||
Some(gid)
|
||||
})
|
||||
.map_err_context(|| {
|
||||
get_message_with_args(
|
||||
"chgrp-error-failed-to-get-attributes",
|
||||
HashMap::from([("file".to_string(), file.quote().to_string())]),
|
||||
)
|
||||
})?
|
||||
.map_err_context(
|
||||
|| translate!("chgrp-error-failed-to-get-attributes", "file" => file.quote()),
|
||||
)?
|
||||
} else {
|
||||
let group = matches
|
||||
.get_one::<String>(options::ARG_GROUP)
|
||||
@@ -86,10 +75,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
|
||||
Err(_) => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
get_message_with_args(
|
||||
"chgrp-error-invalid-user",
|
||||
HashMap::from([("from_group".to_string(), from_group.to_string())]),
|
||||
),
|
||||
translate!("chgrp-error-invalid-user", "from_group" => from_group),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -113,21 +99,21 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(uucore::crate_version!())
|
||||
.about(get_message("chgrp-about"))
|
||||
.override_usage(format_usage(&get_message("chgrp-usage")))
|
||||
.about(translate!("chgrp-about"))
|
||||
.override_usage(format_usage(&translate!("chgrp-usage")))
|
||||
.infer_long_args(true)
|
||||
.disable_help_flag(true)
|
||||
.arg(
|
||||
Arg::new(options::HELP)
|
||||
.long(options::HELP)
|
||||
.help(get_message("chgrp-help-print-help"))
|
||||
.help(translate!("chgrp-help-print-help"))
|
||||
.action(ArgAction::Help),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::verbosity::CHANGES)
|
||||
.short('c')
|
||||
.long(options::verbosity::CHANGES)
|
||||
.help(get_message("chgrp-help-changes"))
|
||||
.help(translate!("chgrp-help-changes"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -139,26 +125,26 @@ pub fn uu_app() -> Command {
|
||||
.arg(
|
||||
Arg::new(options::verbosity::QUIET)
|
||||
.long(options::verbosity::QUIET)
|
||||
.help(get_message("chgrp-help-quiet"))
|
||||
.help(translate!("chgrp-help-quiet"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::verbosity::VERBOSE)
|
||||
.short('v')
|
||||
.long(options::verbosity::VERBOSE)
|
||||
.help(get_message("chgrp-help-verbose"))
|
||||
.help(translate!("chgrp-help-verbose"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::PRESERVE)
|
||||
.long(options::preserve_root::PRESERVE)
|
||||
.help(get_message("chgrp-help-preserve-root"))
|
||||
.help(translate!("chgrp-help-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::NO_PRESERVE)
|
||||
.long(options::preserve_root::NO_PRESERVE)
|
||||
.help(get_message("chgrp-help-no-preserve-root"))
|
||||
.help(translate!("chgrp-help-no-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -166,19 +152,19 @@ pub fn uu_app() -> Command {
|
||||
.long(options::REFERENCE)
|
||||
.value_name("RFILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.help(get_message("chgrp-help-reference")),
|
||||
.help(translate!("chgrp-help-reference")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::FROM)
|
||||
.long(options::FROM)
|
||||
.value_name("GROUP")
|
||||
.help(get_message("chgrp-help-from")),
|
||||
.help(translate!("chgrp-help-from")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::RECURSIVE)
|
||||
.short('R')
|
||||
.long(options::RECURSIVE)
|
||||
.help(get_message("chgrp-help-recursive"))
|
||||
.help(translate!("chgrp-help-recursive"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
// Add common arguments with chgrp, chown & chmod
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user