mirror of
https://github.com/uutils/coreutils
synced 2025-01-21 01:24:40 +00:00
change ~ improve help display for main multi-call binary
This commit is contained in:
parent
c457dfbbc4
commit
8263d31fbb
2 changed files with 15 additions and 12 deletions
|
@ -215,6 +215,7 @@ feat_os_windows_legacy = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = { version="1.3" }
|
lazy_static = { version="1.3" }
|
||||||
|
textwrap = { version="0.11.0", features=["term_size"] }
|
||||||
uucore = { version="0.0.2" }
|
uucore = { version="0.0.2" }
|
||||||
# * uutils
|
# * uutils
|
||||||
arch = { optional=true, path="src/uu/arch" }
|
arch = { optional=true, path="src/uu/arch" }
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// spell-checker:ignore (acronyms/names) Gehring
|
// spell-checker:ignore (acronyms/names) Gehring
|
||||||
// spell-checker:ignore (rustlang) clippy concat rustlang
|
// spell-checker:ignore (rustlang/crates) clippy concat rustlang termwidth textwrap
|
||||||
// spell-checker:ignore (uutils) coreutils uucore uumain uutils sigpipe
|
// spell-checker:ignore (uutils) coreutils sigpipe uucore uumain uutils
|
||||||
// spell-checker:ignore (shell) busybox symlinks
|
// spell-checker:ignore (shell) busybox symlinks
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs"));
|
include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs"));
|
||||||
|
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
extern crate textwrap;
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
@ -37,17 +38,18 @@ lazy_static! {
|
||||||
include!(concat!(env!("OUT_DIR"), "/uutils_map.rs"));
|
include!(concat!(env!("OUT_DIR"), "/uutils_map.rs"));
|
||||||
|
|
||||||
fn usage(utils: &UtilityMap) {
|
fn usage(utils: &UtilityMap) {
|
||||||
println!("{} {}", *NAME, VERSION);
|
println!("{} {} (multi-call binary)\n", *NAME, VERSION);
|
||||||
println!();
|
println!("Usage: {} [function [arguments...]]\n", *NAME);
|
||||||
println!("Usage:");
|
println!("Currently defined functions/utilities:\n");
|
||||||
println!(" {} [util [arguments...]]\n", *NAME);
|
|
||||||
println!("Currently defined functions:");
|
|
||||||
#[allow(clippy::map_clone)]
|
#[allow(clippy::map_clone)]
|
||||||
let mut utils: Vec<&str> = utils.keys().map(|&s| s).collect();
|
let mut utils: Vec<&str> = utils.keys().map(|&s| s).collect();
|
||||||
utils.sort();
|
utils.sort();
|
||||||
for util in utils {
|
let display_list = utils.join(", ");
|
||||||
println!("\t{}", util);
|
let width = std::cmp::min(textwrap::termwidth(), 100) - 4 * 2; // (opinion/heuristic) max 100 chars wide with 4 character side indentions
|
||||||
}
|
println!(
|
||||||
|
"{}",
|
||||||
|
textwrap::indent(&textwrap::fill(&display_list, width), " ")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -98,7 +100,7 @@ fn main() {
|
||||||
std::process::exit(code);
|
std::process::exit(code);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
println!("{}: applet not found", util);
|
println!("{}: function/utility not found", util);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +108,7 @@ fn main() {
|
||||||
usage(&utils);
|
usage(&utils);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else {
|
} else {
|
||||||
println!("{}: applet not found", util);
|
println!("{}: function/utility not found", util);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue