Display options together, in source order (#120)

This commit is contained in:
Kornel 2018-07-14 20:28:47 +01:00 committed by Josh Holmer
parent cb52d8466a
commit e1cf3bf54b

View file

@ -11,7 +11,7 @@ extern crate clap;
extern crate wild; extern crate wild;
extern crate oxipng; extern crate oxipng;
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg, ArgMatches, AppSettings};
use oxipng::AlphaOptim; use oxipng::AlphaOptim;
use oxipng::Deflaters; use oxipng::Deflaters;
use oxipng::Headers; use oxipng::Headers;
@ -28,6 +28,8 @@ fn main() {
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
.author("Joshua Holmer <jholmer.in@gmail.com>") .author("Joshua Holmer <jholmer.in@gmail.com>")
.about("Losslessly improves compression of PNG files") .about("Losslessly improves compression of PNG files")
.setting(AppSettings::DeriveDisplayOrder)
.setting(AppSettings::UnifiedHelpMessage)
.arg(Arg::with_name("files") .arg(Arg::with_name("files")
.help("File(s) to compress (use \"-\" for stdin)") .help("File(s) to compress (use \"-\" for stdin)")
.index(1) .index(1)
@ -51,10 +53,6 @@ fn main() {
.help("Back up modified files") .help("Back up modified files")
.short("b") .short("b")
.long("backup")) .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") .arg(Arg::with_name("recursive")
.help("Recurse into subdirectories") .help("Recurse into subdirectories")
.short("r") .short("r")
@ -78,35 +76,46 @@ fn main() {
.long("stdout") .long("stdout")
.conflicts_with("output_dir") .conflicts_with("output_dir")
.conflicts_with("output_file")) .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") .arg(Arg::with_name("preserve")
.help("Preserve file attributes if possible") .help("Preserve file attributes if possible")
.short("p") .short("p")
.long("preserve")) .long("preserve"))
.arg(Arg::with_name("quiet") .arg(Arg::with_name("pretend")
.help("Run in quiet mode") .help("Do not write any files, only calculate compression gains")
.short("q") .short("P")
.long("quiet") .long("pretend"))
.conflicts_with("verbose")) .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") .arg(Arg::with_name("verbose")
.help("Run in verbose mode") .help("Run in verbose mode")
.short("v") .short("v")
.long("verbose") .long("verbose")
.conflicts_with("quiet")) .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") .arg(Arg::with_name("filters")
.help("PNG delta filters (0-5) - Default: 0,5") .help("PNG delta filters (0-5) - Default: 0,5")
.short("f") .short("f")
@ -118,14 +127,6 @@ fn main() {
Err(_) => Err("Invalid option for filters".to_owned()), 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") .arg(Arg::with_name("compression")
.help("zlib compression levels (1-9) - Default: 9") .help("zlib compression levels (1-9) - Default: 9")
.long("zc") .long("zc")
@ -160,10 +161,6 @@ fn main() {
.possible_value("8k") .possible_value("8k")
.possible_value("16k") .possible_value("16k")
.possible_value("32k")) .possible_value("32k"))
.arg(Arg::with_name("alpha")
.help("Perform additional alpha optimizations")
.short("a")
.long("alpha"))
.arg(Arg::with_name("no-bit-reduction") .arg(Arg::with_name("no-bit-reduction")
.help("No bit depth reduction") .help("No bit depth reduction")
.long("nb")) .long("nb"))
@ -179,20 +176,18 @@ fn main() {
.arg(Arg::with_name("no-recoding") .arg(Arg::with_name("no-recoding")
.help("No IDAT recoding unless necessary") .help("No IDAT recoding unless necessary")
.long("nz")) .long("nz"))
.arg(Arg::with_name("strip") .arg(Arg::with_name("fix")
.help("Strip metadata objects ['safe', 'all', or comma-separated list]") .help("Enable error recovery")
.long("strip") .long("fix"))
.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("zopfli") .arg(Arg::with_name("zopfli")
.help("Use the slower but better compressing Zopfli algorithm, overrides zlib-specific options") .help("Use the slower but better compressing Zopfli algorithm, overrides zlib-specific options")
.short("Z") .short("Z")
.long("zopfli")) .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") .arg(Arg::with_name("threads")
.help("Set number of threads to use - default 1.5x CPU cores") .help("Set number of threads to use - default 1.5x CPU cores")
.long("threads") .long("threads")