aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_cli/src/main.rs')
-rw-r--r--crates/ra_cli/src/main.rs103
1 files changed, 96 insertions, 7 deletions
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index f0daaaf15..9a7f9724e 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -2,7 +2,6 @@
2 2
3mod analysis_stats; 3mod analysis_stats;
4mod analysis_bench; 4mod analysis_bench;
5mod help;
6mod progress_report; 5mod progress_report;
7 6
8use std::{error::Error, fmt::Write, io::Read}; 7use std::{error::Error, fmt::Write, io::Read};
@@ -46,9 +45,20 @@ fn main() -> Result<()> {
46 match subcommand.as_str() { 45 match subcommand.as_str() {
47 "parse" => { 46 "parse" => {
48 if matches.contains(["-h", "--help"]) { 47 if matches.contains(["-h", "--help"]) {
49 eprintln!("{}", help::PARSE_HELP); 48 eprintln!(
49 "\
50ra-cli-parse
51
52USAGE:
53 ra_cli parse [FLAGS]
54
55FLAGS:
56 -h, --help Prints help inforamtion
57 --no-dump"
58 );
50 return Ok(()); 59 return Ok(());
51 } 60 }
61
52 let no_dump = matches.contains("--no-dump"); 62 let no_dump = matches.contains("--no-dump");
53 matches.finish().or_else(handle_extra_flags)?; 63 matches.finish().or_else(handle_extra_flags)?;
54 64
@@ -61,10 +71,21 @@ fn main() -> Result<()> {
61 } 71 }
62 "symbols" => { 72 "symbols" => {
63 if matches.contains(["-h", "--help"]) { 73 if matches.contains(["-h", "--help"]) {
64 eprintln!("{}", help::SYMBOLS_HELP); 74 eprintln!(
75 "\
76ra-cli-symbols
77
78USAGE:
79 ra_cli highlight [FLAGS]
80
81FLAGS:
82 -h, --help Prints help inforamtion"
83 );
65 return Ok(()); 84 return Ok(());
66 } 85 }
86
67 matches.finish().or_else(handle_extra_flags)?; 87 matches.finish().or_else(handle_extra_flags)?;
88
68 let file = file()?; 89 let file = file()?;
69 for s in file_structure(&file) { 90 for s in file_structure(&file) {
70 println!("{:?}", s); 91 println!("{:?}", s);
@@ -72,20 +93,51 @@ fn main() -> Result<()> {
72 } 93 }
73 "highlight" => { 94 "highlight" => {
74 if matches.contains(["-h", "--help"]) { 95 if matches.contains(["-h", "--help"]) {
75 eprintln!("{}", help::HIGHLIGHT_HELP); 96 eprintln!(
97 "\
98ra-cli-highlight
99
100USAGE:
101 ra_cli highlight [FLAGS]
102
103FLAGS:
104 -h, --help Prints help information
105 -r, --rainbow"
106 );
76 return Ok(()); 107 return Ok(());
77 } 108 }
109
78 let rainbow_opt = matches.contains(["-r", "--rainbow"]); 110 let rainbow_opt = matches.contains(["-r", "--rainbow"]);
79 matches.finish().or_else(handle_extra_flags)?; 111 matches.finish().or_else(handle_extra_flags)?;
112
80 let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); 113 let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
81 let html = analysis.highlight_as_html(file_id, rainbow_opt).unwrap(); 114 let html = analysis.highlight_as_html(file_id, rainbow_opt).unwrap();
82 println!("{}", html); 115 println!("{}", html);
83 } 116 }
84 "analysis-stats" => { 117 "analysis-stats" => {
85 if matches.contains(["-h", "--help"]) { 118 if matches.contains(["-h", "--help"]) {
86 eprintln!("{}", help::ANALYSIS_STATS_HELP); 119 eprintln!(
120 "\
121ra-cli-analysis-stats
122
123USAGE:
124 ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH]
125
126FLAGS:
127 -h, --help Prints help information
128 --memory-usage
129 -v, --verbose
130 -q, --quiet
131
132OPTIONS:
133 -o <ONLY>
134
135ARGS:
136 <PATH>"
137 );
87 return Ok(()); 138 return Ok(());
88 } 139 }
140
89 let verbosity = match ( 141 let verbosity = match (
90 matches.contains(["-vv", "--spammy"]), 142 matches.contains(["-vv", "--spammy"]),
91 matches.contains(["-v", "--verbose"]), 143 matches.contains(["-v", "--verbose"]),
@@ -110,6 +162,8 @@ fn main() -> Result<()> {
110 } 162 }
111 trailing.pop().unwrap() 163 trailing.pop().unwrap()
112 }; 164 };
165 matches.finish().or_else(handle_extra_flags)?;
166
113 analysis_stats::run( 167 analysis_stats::run(
114 verbosity, 168 verbosity,
115 memory_usage, 169 memory_usage,
@@ -121,9 +175,27 @@ fn main() -> Result<()> {
121 } 175 }
122 "analysis-bench" => { 176 "analysis-bench" => {
123 if matches.contains(["-h", "--help"]) { 177 if matches.contains(["-h", "--help"]) {
124 eprintln!("{}", help::ANALYSIS_BENCH_HELP); 178 eprintln!(
179 "\
180ra_cli-analysis-bench
181
182USAGE:
183 ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH]
184
185FLAGS:
186 -h, --help Prints help information
187 -v, --verbose
188
189OPTIONS:
190 --complete <PATH:LINE:COLUMN> Compute completions at this location
191 --highlight <PATH> Hightlight this file
192
193ARGS:
194 <PATH> Project to analyse"
195 );
125 return Ok(()); 196 return Ok(());
126 } 197 }
198
127 let verbose = matches.contains(["-v", "--verbose"]); 199 let verbose = matches.contains(["-v", "--verbose"]);
128 let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default(); 200 let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default();
129 let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?; 201 let highlight_path: Option<String> = matches.opt_value_from_str("--highlight")?;
@@ -138,9 +210,26 @@ fn main() -> Result<()> {
138 ), 210 ),
139 }; 211 };
140 matches.finish().or_else(handle_extra_flags)?; 212 matches.finish().or_else(handle_extra_flags)?;
213
141 analysis_bench::run(verbose, path.as_ref(), op)?; 214 analysis_bench::run(verbose, path.as_ref(), op)?;
142 } 215 }
143 _ => eprintln!("{}", help::GLOBAL_HELP), 216 _ => eprintln!(
217 "\
218ra-cli
219
220USAGE:
221 ra_cli <SUBCOMMAND>
222
223FLAGS:
224 -h, --help Prints help information
225
226SUBCOMMANDS:
227 analysis-bench
228 analysis-stats
229 highlight
230 parse
231 symbols"
232 ),
144 } 233 }
145 Ok(()) 234 Ok(())
146} 235}