mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
Merge pull request #567 from kamalmarhubi/config-docs-flag
Move config help to dedicated --config-help flag
This commit is contained in:
commit
1c0934772c
@ -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 {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user