From ae13bbcc98af5040aac39f4237ce3ff363a19974 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Sat, 7 Nov 2015 19:03:25 -0500 Subject: [PATCH] Move config help to dedicated --config-help flag The existing help output is very verbose, overflowing a 50+ line terminal. This moves the configuration options to a separate help flag to make a mistyped command less annoying! --- src/bin/rustfmt.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index 9528105124f..2789b5f6cdd 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -33,6 +33,8 @@ enum Operation { Format(PathBuf, WriteMode), /// Print the help message. Help, + /// Print detailed configuration help. + ConfigHelp, /// Invalid program input, including reason. InvalidInput(String), /// No file specified, read from stdin @@ -80,6 +82,10 @@ fn execute() -> i32 { "mode to write in (not usable when piping from stdin)", "[replace|overwrite|display|diff|coverage]"); + opts.optflag("", + "config-help", + "show details of rustfmt configuration options"); + let operation = determine_operation(&opts, env::args().skip(1)); match operation { @@ -91,6 +97,10 @@ fn execute() -> i32 { print_usage(&opts, ""); 0 } + Operation::ConfigHelp => { + Config::print_docs(); + 0 + } Operation::Stdin(input, write_mode) => { // try to read config from local directory let config = match lookup_and_read_project_file(&Path::new(".")) { @@ -137,7 +147,6 @@ fn print_usage(opts: &Options, reason: &str) { reason, env::current_exe().unwrap().display()); println!("{}", opts.usage(&reason)); - Config::print_docs(); } fn determine_operation(opts: &Options, args: I) -> Operation @@ -152,6 +161,10 @@ fn determine_operation(opts: &Options, args: I) -> Operation return Operation::Help; } + if matches.opt_present("config-help") { + return Operation::ConfigHelp; + } + // if no file argument is supplied, read from stdin if matches.free.len() == 0 {