aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/bin/args.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs
index b14409c39..8e3ca9343 100644
--- a/crates/rust-analyzer/src/bin/args.rs
+++ b/crates/rust-analyzer/src/bin/args.rs
@@ -75,6 +75,10 @@ impl Args {
75 let subcommand = match matches.subcommand()? { 75 let subcommand = match matches.subcommand()? {
76 Some(it) => it, 76 Some(it) => it,
77 None => { 77 None => {
78 if matches.contains(["-h", "--help"]) {
79 print_subcommands();
80 return Ok(Err(HelpPrinted));
81 }
78 matches.finish().or_else(handle_extra_flags)?; 82 matches.finish().or_else(handle_extra_flags)?;
79 return Ok(Ok(Args { verbosity, command: Command::RunServer })); 83 return Ok(Ok(Args { verbosity, command: Command::RunServer }));
80 } 84 }
@@ -267,8 +271,17 @@ ARGS:
267 } 271 }
268 "proc-macro" => Command::ProcMacro, 272 "proc-macro" => Command::ProcMacro,
269 _ => { 273 _ => {
270 eprintln!( 274 print_subcommands();
271 "\ 275 return Ok(Err(HelpPrinted));
276 }
277 };
278 Ok(Ok(Args { verbosity, command }))
279 }
280}
281
282fn print_subcommands() {
283 eprintln!(
284 "\
272rust-analyzer 285rust-analyzer
273 286
274USAGE: 287USAGE:
@@ -285,12 +298,7 @@ SUBCOMMANDS:
285 proc-macro 298 proc-macro
286 parse 299 parse
287 symbols" 300 symbols"
288 ); 301 )
289 return Ok(Err(HelpPrinted));
290 }
291 };
292 Ok(Ok(Args { verbosity, command }))
293 }
294} 302}
295 303
296pub(crate) struct HelpPrinted; 304pub(crate) struct HelpPrinted;