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!
This commit is contained in:
Kamal Marhubi 2015-11-07 19:03:25 -05:00
parent 0d0606c3c0
commit ae13bbcc98

View File

@ -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<I>(opts: &Options, args: I) -> Operation
@ -152,6 +161,10 @@ fn determine_operation<I>(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 {