mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +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),
|
Format(PathBuf, WriteMode),
|
||||||
/// Print the help message.
|
/// Print the help message.
|
||||||
Help,
|
Help,
|
||||||
|
/// Print detailed configuration help.
|
||||||
|
ConfigHelp,
|
||||||
/// Invalid program input, including reason.
|
/// Invalid program input, including reason.
|
||||||
InvalidInput(String),
|
InvalidInput(String),
|
||||||
/// No file specified, read from stdin
|
/// No file specified, read from stdin
|
||||||
@ -80,6 +82,10 @@ fn execute() -> i32 {
|
|||||||
"mode to write in (not usable when piping from stdin)",
|
"mode to write in (not usable when piping from stdin)",
|
||||||
"[replace|overwrite|display|diff|coverage]");
|
"[replace|overwrite|display|diff|coverage]");
|
||||||
|
|
||||||
|
opts.optflag("",
|
||||||
|
"config-help",
|
||||||
|
"show details of rustfmt configuration options");
|
||||||
|
|
||||||
let operation = determine_operation(&opts, env::args().skip(1));
|
let operation = determine_operation(&opts, env::args().skip(1));
|
||||||
|
|
||||||
match operation {
|
match operation {
|
||||||
@ -91,6 +97,10 @@ fn execute() -> i32 {
|
|||||||
print_usage(&opts, "");
|
print_usage(&opts, "");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
Operation::ConfigHelp => {
|
||||||
|
Config::print_docs();
|
||||||
|
0
|
||||||
|
}
|
||||||
Operation::Stdin(input, write_mode) => {
|
Operation::Stdin(input, write_mode) => {
|
||||||
// try to read config from local directory
|
// try to read config from local directory
|
||||||
let config = match lookup_and_read_project_file(&Path::new(".")) {
|
let config = match lookup_and_read_project_file(&Path::new(".")) {
|
||||||
@ -137,7 +147,6 @@ fn print_usage(opts: &Options, reason: &str) {
|
|||||||
reason,
|
reason,
|
||||||
env::current_exe().unwrap().display());
|
env::current_exe().unwrap().display());
|
||||||
println!("{}", opts.usage(&reason));
|
println!("{}", opts.usage(&reason));
|
||||||
Config::print_docs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn determine_operation<I>(opts: &Options, args: I) -> Operation
|
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;
|
return Operation::Help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches.opt_present("config-help") {
|
||||||
|
return Operation::ConfigHelp;
|
||||||
|
}
|
||||||
|
|
||||||
// if no file argument is supplied, read from stdin
|
// if no file argument is supplied, read from stdin
|
||||||
if matches.free.len() == 0 {
|
if matches.free.len() == 0 {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user