mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
Fix to build on Rust 1.32.0 and formatting
This commit is contained in:
parent
5cea5faee0
commit
8377abadb6
3 changed files with 31 additions and 17 deletions
|
@ -36,7 +36,7 @@ fn usage<T>(utils: &UtilityMap<T>, name: &str) {
|
||||||
|
|
||||||
fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
|
fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
Some(s) if !s.is_empty() => PathBuf::from(s),
|
Some(ref s) if !s.is_empty() => PathBuf::from(s),
|
||||||
_ => std::env::current_exe().unwrap(),
|
_ => std::env::current_exe().unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,22 +61,21 @@ fn main() {
|
||||||
|
|
||||||
// binary name equals prefixed util name?
|
// binary name equals prefixed util name?
|
||||||
// * prefix/stem may be any string ending in a non-alphanumeric character
|
// * prefix/stem may be any string ending in a non-alphanumeric character
|
||||||
let utilname =
|
let utilname = if let Some(util) = utils.keys().find(|util| {
|
||||||
if let Some(util) = utils.keys().find(|util| {
|
binary_as_util.ends_with(*util)
|
||||||
binary_as_util.ends_with(*util)
|
&& !(&binary_as_util[..binary_as_util.len() - (*util).len()])
|
||||||
&& !(&binary_as_util[..binary_as_util.len() - (*util).len()])
|
.ends_with(char::is_alphanumeric)
|
||||||
.ends_with(char::is_alphanumeric)
|
}) {
|
||||||
}) {
|
// prefixed util => replace 0th (aka, executable name) argument
|
||||||
// prefixed util => replace 0th (aka, executable name) argument
|
Some(OsString::from(*util))
|
||||||
Some(OsString::from(*util))
|
} else {
|
||||||
} else {
|
// unmatched binary name => regard as multi-binary container and advance argument list
|
||||||
// unmatched binary name => regard as multi-binary container and advance argument list
|
args.next()
|
||||||
args.next()
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// 0th argument equals util name?
|
// 0th argument equals util name?
|
||||||
if let Some(util_os) = utilname {
|
if let Some(util_os) = utilname {
|
||||||
let util = util_os.as_os_str().to_string_lossy();
|
let util = util_os.as_os_str().to_string_lossy();
|
||||||
|
|
||||||
match utils.get(&util[..]) {
|
match utils.get(&util[..]) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
|
@ -90,7 +89,10 @@ fn main() {
|
||||||
|
|
||||||
match utils.get(&util[..]) {
|
match utils.get(&util[..]) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
let code = uumain((vec![util_os, OsString::from("--help")].into_iter()).chain(args));
|
let code = uumain(
|
||||||
|
(vec![util_os, OsString::from("--help")].into_iter())
|
||||||
|
.chain(args),
|
||||||
|
);
|
||||||
io::stdout().flush().expect("could not flush stdout");
|
io::stdout().flush().expect("could not flush stdout");
|
||||||
process::exit(code);
|
process::exit(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,11 @@ static LONG_HELP: &str = "
|
||||||
";
|
";
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
base_common::execute(args.collect_str(), SYNTAX, SUMMARY, LONG_HELP, Format::Base32)
|
base_common::execute(
|
||||||
|
args.collect_str(),
|
||||||
|
SYNTAX,
|
||||||
|
SUMMARY,
|
||||||
|
LONG_HELP,
|
||||||
|
Format::Base32,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,11 @@ static LONG_HELP: &str = "
|
||||||
";
|
";
|
||||||
|
|
||||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
base_common::execute(args.collect_str(), SYNTAX, SUMMARY, LONG_HELP, Format::Base64)
|
base_common::execute(
|
||||||
|
args.collect_str(),
|
||||||
|
SYNTAX,
|
||||||
|
SUMMARY,
|
||||||
|
LONG_HELP,
|
||||||
|
Format::Base64,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue