Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't panic on rust-analyzer --help #4082

Merged
merged 1 commit into from Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions crates/rust-analyzer/src/bin/args.rs
Expand Up @@ -75,6 +75,10 @@ impl Args {
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 }));
}
Expand Down Expand Up @@ -267,8 +271,17 @@ ARGS:
}
"proc-macro" => Command::ProcMacro,
_ => {
eprintln!(
"\
print_subcommands();
return Ok(Err(HelpPrinted));
}
};
Ok(Ok(Args { verbosity, command }))
}
}

fn print_subcommands() {
eprintln!(
"\
rust-analyzer

USAGE:
Expand All @@ -285,12 +298,7 @@ SUBCOMMANDS:
proc-macro
parse
symbols"
);
return Ok(Err(HelpPrinted));
}
};
Ok(Ok(Args { verbosity, command }))
}
)
}

pub(crate) struct HelpPrinted;
Expand Down