Don't panic on rust-analyzer --help
Special case handling for `-h` and `--help` if no subcommand is given. Closes #4068
This commit is contained in:
parent
546f9ee7a7
commit
165f5c6577
@ -75,6 +75,10 @@ pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
|
||||
let subcommand = match matches.subcommand()? {
|
||||
Some(it) => it,
|
||||
None => {
|
||||
if matches.contains(["-h", "--help"]) {
|
||||
print_subcommands();
|
||||
return Ok(Err(HelpPrinted));
|
||||
}
|
||||
matches.finish().or_else(handle_extra_flags)?;
|
||||
return Ok(Ok(Args { verbosity, command: Command::RunServer }));
|
||||
}
|
||||
@ -267,8 +271,17 @@ pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
|
||||
}
|
||||
"proc-macro" => Command::ProcMacro,
|
||||
_ => {
|
||||
eprintln!(
|
||||
"\
|
||||
print_subcommands();
|
||||
return Ok(Err(HelpPrinted));
|
||||
}
|
||||
};
|
||||
Ok(Ok(Args { verbosity, command }))
|
||||
}
|
||||
}
|
||||
|
||||
fn print_subcommands() {
|
||||
eprintln!(
|
||||
"\
|
||||
rust-analyzer
|
||||
|
||||
USAGE:
|
||||
@ -285,12 +298,7 @@ pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
|
||||
proc-macro
|
||||
parse
|
||||
symbols"
|
||||
);
|
||||
return Ok(Err(HelpPrinted));
|
||||
}
|
||||
};
|
||||
Ok(Ok(Args { verbosity, command }))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) struct HelpPrinted;
|
||||
|
Loading…
Reference in New Issue
Block a user