From e1cf3bf54b0a52cb2eaf177962d9e43cea370560 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sat, 14 Jul 2018 20:28:47 +0100 Subject: [PATCH] Display options together, in source order (#120) --- src/main.rs | 89 +++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/src/main.rs b/src/main.rs index cbc8c102..7a175ce4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ extern crate clap; extern crate wild; extern crate oxipng; -use clap::{App, Arg, ArgMatches}; +use clap::{App, Arg, ArgMatches, AppSettings}; use oxipng::AlphaOptim; use oxipng::Deflaters; use oxipng::Headers; @@ -28,6 +28,8 @@ fn main() { .version(env!("CARGO_PKG_VERSION")) .author("Joshua Holmer ") .about("Losslessly improves compression of PNG files") + .setting(AppSettings::DeriveDisplayOrder) + .setting(AppSettings::UnifiedHelpMessage) .arg(Arg::with_name("files") .help("File(s) to compress (use \"-\" for stdin)") .index(1) @@ -51,10 +53,6 @@ fn main() { .help("Back up modified files") .short("b") .long("backup")) - .arg(Arg::with_name("force") - .help("Write output even if larger than the original") - .short("F") - .long("force")) .arg(Arg::with_name("recursive") .help("Recurse into subdirectories") .short("r") @@ -78,35 +76,46 @@ fn main() { .long("stdout") .conflicts_with("output_dir") .conflicts_with("output_file")) - .arg(Arg::with_name("fix") - .help("Enable error recovery") - .long("fix")) - .arg(Arg::with_name("no-clobber") - .help("Do not overwrite existing files") - .long("no-clobber")) - .arg(Arg::with_name("pretend") - .help("Do not write any files, only calculate compression gains") - .short("P") - .long("pretend")) - .arg(Arg::with_name("timeout") - .help("Maximum amount of time, in seconds, to spend on optimizations") - .takes_value(true) - .value_name("secs") - .long("timeout")) .arg(Arg::with_name("preserve") .help("Preserve file attributes if possible") .short("p") .long("preserve")) - .arg(Arg::with_name("quiet") - .help("Run in quiet mode") - .short("q") - .long("quiet") - .conflicts_with("verbose")) + .arg(Arg::with_name("pretend") + .help("Do not write any files, only calculate compression gains") + .short("P") + .long("pretend")) + .arg(Arg::with_name("strip-safe") + .help("Strip safely-removable metadata objects") + .short("s") + .conflicts_with("strip")) + .arg(Arg::with_name("strip") + .help("Strip metadata objects ['safe', 'all', or comma-separated list]") + .long("strip") + .takes_value(true) + .value_name("mode") + .conflicts_with("strip-safe")) + .arg(Arg::with_name("alpha") + .help("Perform additional alpha optimizations") + .short("a") + .long("alpha")) + .arg(Arg::with_name("interlace") + .help("PNG interlace type") + .short("i") + .long("interlace") + .takes_value(true) + .value_name("0/1") + .possible_value("0") + .possible_value("1")) .arg(Arg::with_name("verbose") .help("Run in verbose mode") .short("v") .long("verbose") .conflicts_with("quiet")) + .arg(Arg::with_name("quiet") + .help("Run in quiet mode") + .short("q") + .long("quiet") + .conflicts_with("verbose")) .arg(Arg::with_name("filters") .help("PNG delta filters (0-5) - Default: 0,5") .short("f") @@ -118,14 +127,6 @@ fn main() { Err(_) => Err("Invalid option for filters".to_owned()), } })) - .arg(Arg::with_name("interlace") - .help("PNG interlace type") - .short("i") - .long("interlace") - .takes_value(true) - .value_name("0/1") - .possible_value("0") - .possible_value("1")) .arg(Arg::with_name("compression") .help("zlib compression levels (1-9) - Default: 9") .long("zc") @@ -160,10 +161,6 @@ fn main() { .possible_value("8k") .possible_value("16k") .possible_value("32k")) - .arg(Arg::with_name("alpha") - .help("Perform additional alpha optimizations") - .short("a") - .long("alpha")) .arg(Arg::with_name("no-bit-reduction") .help("No bit depth reduction") .long("nb")) @@ -179,20 +176,18 @@ fn main() { .arg(Arg::with_name("no-recoding") .help("No IDAT recoding unless necessary") .long("nz")) - .arg(Arg::with_name("strip") - .help("Strip metadata objects ['safe', 'all', or comma-separated list]") - .long("strip") - .takes_value(true) - .value_name("mode") - .conflicts_with("strip-safe")) - .arg(Arg::with_name("strip-safe") - .help("Strip safely-removable metadata objects") - .short("s") - .conflicts_with("strip")) + .arg(Arg::with_name("fix") + .help("Enable error recovery") + .long("fix")) .arg(Arg::with_name("zopfli") .help("Use the slower but better compressing Zopfli algorithm, overrides zlib-specific options") .short("Z") .long("zopfli")) + .arg(Arg::with_name("timeout") + .help("Maximum amount of time, in seconds, to spend on optimizations") + .takes_value(true) + .value_name("secs") + .long("timeout")) .arg(Arg::with_name("threads") .help("Set number of threads to use - default 1.5x CPU cores") .long("threads")