From a3c85cdc41e3622c85a54284c497815a49906eb2 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 14 May 2018 11:07:54 +1200 Subject: [PATCH] Reorder the --help message --- rustfmt.toml | 2 -- src/bin/main.rs | 63 +++++++++++++++++++++---------------------- src/config/options.rs | 2 +- src/config/summary.rs | 7 ----- 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 9b935b0a287..e69de29bb2d 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +0,0 @@ -error_on_line_overflow = true -error_on_unformatted = true diff --git a/src/bin/main.rs b/src/bin/main.rs index 03105a90220..2c7bf5a2445 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -90,40 +90,33 @@ enum HelpOp { fn make_opts() -> Options { let mut opts = Options::new(); - // Sorted in alphabetical order. - opts.optflag("", "backup", "Backup any modified files."); opts.optflag( "", "check", "Run in 'check' mode. Exits with 0 if input if formatted correctly. Exits \ with 1 and prints a diff if formatting is required.", ); + let is_nightly = is_nightly(); + let emit_opts = if is_nightly { + "[files|stdout|coverage|checkstyle]" + } else { + "[files|stdout]" + }; + opts.optopt("", "emit", "What data to emit and how", emit_opts); + opts.optflag("", "backup", "Backup any modified files."); + opts.optopt( + "", + "config-path", + "Recursively searches the given path for the rustfmt.toml config file. If not \ + found reverts to the input file path", + "[Path for the configuration file]", + ); opts.optopt( "", "color", "Use colored output (if supported)", "[always|never|auto]", ); - opts.optopt( - "", - "config-path", - "Recursively searches the given path for the rustfmt.toml config file. If not \ - found reverts to the input file path", - "[Path for the configuration file]", - ); - let is_nightly = is_nightly(); - let emit_opts = if is_nightly { - "[files|stdout|coverage|checkstyle]" - } else { - "[files|stdout]" - }; - opts.optopt("", "emit", "What data to emit and how", emit_opts); - opts.optflagopt( - "h", - "help", - "Show this message or help about a specific topic: `config` or `file-lines`", - "=TOPIC", - ); opts.optopt( "", "print-config", @@ -131,9 +124,6 @@ fn make_opts() -> Options { subset of the current config file used for formatting the current program.", "[minimal|default] PATH", ); - opts.optflag("v", "verbose", "Print verbose output"); - opts.optflag("q", "quiet", "Print less output"); - opts.optflag("V", "version", "Show version information"); if is_nightly { opts.optflag( @@ -141,12 +131,6 @@ fn make_opts() -> Options { "unstable-features", "Enables unstable features. Only available on nightly channel.", ); - opts.optflag( - "", - "error-on-unformatted", - "Error if unable to get comments or string literals within max_width, \ - or they are left with trailing whitespaces (unstable).", - ); opts.optopt( "", "file-lines", @@ -154,6 +138,12 @@ fn make_opts() -> Options { more detail (unstable).", "JSON", ); + opts.optflag( + "", + "error-on-unformatted", + "Error if unable to get comments or string literals within max_width, \ + or they are left with trailing whitespaces (unstable).", + ); opts.optflag( "", "skip-children", @@ -161,6 +151,16 @@ fn make_opts() -> Options { ); } + opts.optflag("v", "verbose", "Print verbose output"); + opts.optflag("q", "quiet", "Print less output"); + opts.optflag("V", "version", "Show version information"); + opts.optflagopt( + "h", + "help", + "Show this message or help about a specific topic: `config` or `file-lines`", + "=TOPIC", + ); + opts } @@ -177,7 +177,6 @@ fn execute(opts: &Options) -> FmtResult<(WriteMode, Summary)> { match determine_operation(&matches)? { Operation::Help(HelpOp::None) => { print_usage_to_stdout(opts, ""); - Summary::print_exit_codes(); Ok((WriteMode::None, Summary::default())) } Operation::Help(HelpOp::Config) => { diff --git a/src/config/options.rs b/src/config/options.rs index 65915225860..06580339d9e 100644 --- a/src/config/options.rs +++ b/src/config/options.rs @@ -360,7 +360,7 @@ impl CliOptions { options.unstable_features = matches.opt_present("unstable-features"); } - if !options.unstable_features { + if options.unstable_features { if matches.opt_present("skip-children") { options.skip_children = Some(true); } diff --git a/src/config/summary.rs b/src/config/summary.rs index e436856d286..d44c69b04a6 100644 --- a/src/config/summary.rs +++ b/src/config/summary.rs @@ -102,13 +102,6 @@ impl Summary { self.has_parsing_errors |= other.has_parsing_errors; self.has_diff |= other.has_diff; } - - pub fn print_exit_codes() { - let exit_codes = r#"Exit Codes: - 0 = No errors - 1 = Encountered error in formatting code"#; - println!("{}", exit_codes); - } } #[derive(Clone, Copy, Debug)]