diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/bin/args.rs | 24 |
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 | |||
282 | fn print_subcommands() { | ||
283 | eprintln!( | ||
284 | "\ | ||
272 | rust-analyzer | 285 | rust-analyzer |
273 | 286 | ||
274 | USAGE: | 287 | USAGE: |
@@ -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 | ||
296 | pub(crate) struct HelpPrinted; | 304 | pub(crate) struct HelpPrinted; |