From fa482a9fee6596f9b3021b188a2120873d5bb0d3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 17 Feb 2020 18:03:48 +0100 Subject: Move interesting stuff to main --- crates/ra_cli/src/main.rs | 75 ++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'crates/ra_cli/src') diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 42f0b3e17..f952d0f6c 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -18,7 +18,41 @@ fn main() -> Result<()> { env_logger::try_init()?; let command = Command::from_args()?; - command.run()?; + match command { + Command::Parse { no_dump } => { + let _p = profile("parsing"); + let file = file()?; + if !no_dump { + println!("{:#?}", file.syntax()); + } + std::mem::forget(file); + } + Command::Symbols => { + let file = file()?; + for s in file_structure(&file) { + println!("{:?}", s); + } + } + Command::Highlight { rainbow } => { + let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); + let html = analysis.highlight_as_html(file_id, rainbow).unwrap(); + println!("{}", html); + } + Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } => { + analysis_stats::run( + verbosity, + memory_usage, + path.as_ref(), + only.as_ref().map(String::as_ref), + with_deps, + randomize, + )?; + } + Command::Bench { verbose, path, op } => { + analysis_bench::run(verbose, path.as_ref(), op)?; + } + Command::HelpPrinted => (), + } Ok(()) } @@ -246,45 +280,6 @@ SUBCOMMANDS: }; Ok(command) } - - fn run(self) -> Result<()> { - match self { - Command::Parse { no_dump } => { - let _p = profile("parsing"); - let file = file()?; - if !no_dump { - println!("{:#?}", file.syntax()); - } - std::mem::forget(file); - } - Command::Symbols => { - let file = file()?; - for s in file_structure(&file) { - println!("{:?}", s); - } - } - Command::Highlight { rainbow } => { - let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); - let html = analysis.highlight_as_html(file_id, rainbow).unwrap(); - println!("{}", html); - } - Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } => { - analysis_stats::run( - verbosity, - memory_usage, - path.as_ref(), - only.as_ref().map(String::as_ref), - with_deps, - randomize, - )?; - } - Command::Bench { verbose, path, op } => { - analysis_bench::run(verbose, path.as_ref(), op)?; - } - Command::HelpPrinted => (), - } - Ok(()) - } } fn handle_extra_flags(e: pico_args::Error) -> Result<()> { -- cgit v1.2.3