1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #1088 from flyrry/cleanup_help

make cp print usage correctly
This commit is contained in:
Nathan Ross 2017-11-14 17:55:31 -05:00 committed by GitHub
commit 517a263e25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -212,7 +212,7 @@ pub struct Options {
}
static VERSION: &str = env!("CARGO_PKG_VERSION");
static USAGE: &str = "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.";
static ABOUT: &str = "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.";
static EXIT_OK: i32 = 0;
static EXIT_ERR: i32 = 1;
@ -221,12 +221,10 @@ fn print_version() {
println!("{} {}", executable!(), VERSION);
}
/// Prints usage/help
fn get_about(usage: &str) -> String {
format!("Usage: {0} [OPTION]... [-T] SOURCE DEST
or: {0} [OPTION]... SOURCE... DIRECTORY
or: {0} [OPTION]... -t DIRECTORY SOURCE...
{1}", executable!(), usage)
fn get_usage() -> String {
format!("{0} [OPTION]... [-T] SOURCE DEST
{0} [OPTION]... SOURCE... DIRECTORY
{0} [OPTION]... -t DIRECTORY SOURCE...", executable!())
}
@ -278,10 +276,11 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[
pub fn uumain(args: Vec<String>) -> i32 {
let about = get_about(USAGE);
let usage = get_usage();
let matches = App::new(executable!())
.version(VERSION)
.about(&about[..])
.about(ABOUT)
.usage(&usage[..])
.arg(Arg::with_name(OPT_TARGET_DIRECTORY)
.short("t")
.conflicts_with(OPT_NO_TARGET_DIRECTORY)