diff options
Diffstat (limited to 'crates/ra_cli')
-rw-r--r-- | crates/ra_cli/src/help.rs | 75 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 103 |
2 files changed, 96 insertions, 82 deletions
diff --git a/crates/ra_cli/src/help.rs b/crates/ra_cli/src/help.rs deleted file mode 100644 index d3c4c7d0b..000000000 --- a/crates/ra_cli/src/help.rs +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | pub const GLOBAL_HELP: &str = "ra-cli | ||
4 | |||
5 | USAGE: | ||
6 | ra_cli <SUBCOMMAND> | ||
7 | |||
8 | FLAGS: | ||
9 | -h, --help Prints help information | ||
10 | |||
11 | SUBCOMMANDS: | ||
12 | analysis-bench | ||
13 | analysis-stats | ||
14 | highlight | ||
15 | parse | ||
16 | symbols"; | ||
17 | |||
18 | pub const ANALYSIS_BENCH_HELP: &str = "ra_cli-analysis-bench | ||
19 | |||
20 | USAGE: | ||
21 | ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH] | ||
22 | |||
23 | FLAGS: | ||
24 | -h, --help Prints help information | ||
25 | -v, --verbose | ||
26 | |||
27 | OPTIONS: | ||
28 | --complete <PATH:LINE:COLUMN> Compute completions at this location | ||
29 | --highlight <PATH> Hightlight this file | ||
30 | |||
31 | ARGS: | ||
32 | <PATH> Project to analyse"; | ||
33 | |||
34 | pub const ANALYSIS_STATS_HELP: &str = "ra-cli-analysis-stats | ||
35 | |||
36 | USAGE: | ||
37 | ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH] | ||
38 | |||
39 | FLAGS: | ||
40 | -h, --help Prints help information | ||
41 | --memory-usage | ||
42 | -v, --verbose | ||
43 | -q, --quiet | ||
44 | |||
45 | OPTIONS: | ||
46 | -o <ONLY> | ||
47 | |||
48 | ARGS: | ||
49 | <PATH>"; | ||
50 | |||
51 | pub const HIGHLIGHT_HELP: &str = "ra-cli-highlight | ||
52 | |||
53 | USAGE: | ||
54 | ra_cli highlight [FLAGS] | ||
55 | |||
56 | FLAGS: | ||
57 | -h, --help Prints help information | ||
58 | -r, --rainbow"; | ||
59 | |||
60 | pub const SYMBOLS_HELP: &str = "ra-cli-symbols | ||
61 | |||
62 | USAGE: | ||
63 | ra_cli highlight [FLAGS] | ||
64 | |||
65 | FLAGS: | ||
66 | -h, --help Prints help inforamtion"; | ||
67 | |||
68 | pub const PARSE_HELP: &str = "ra-cli-parse | ||
69 | |||
70 | USAGE: | ||
71 | ra_cli parse [FLAGS] | ||
72 | |||
73 | FLAGS: | ||
74 | -h, --help Prints help inforamtion | ||
75 | --no-dump"; | ||
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 | ||
3 | mod analysis_stats; | 3 | mod analysis_stats; |
4 | mod analysis_bench; | 4 | mod analysis_bench; |
5 | mod help; | ||
6 | mod progress_report; | 5 | mod progress_report; |
7 | 6 | ||
8 | use std::{error::Error, fmt::Write, io::Read}; | 7 | use 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 | "\ | ||
50 | ra-cli-parse | ||
51 | |||
52 | USAGE: | ||
53 | ra_cli parse [FLAGS] | ||
54 | |||
55 | FLAGS: | ||
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 | "\ | ||
76 | ra-cli-symbols | ||
77 | |||
78 | USAGE: | ||
79 | ra_cli highlight [FLAGS] | ||
80 | |||
81 | FLAGS: | ||
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 | "\ | ||
98 | ra-cli-highlight | ||
99 | |||
100 | USAGE: | ||
101 | ra_cli highlight [FLAGS] | ||
102 | |||
103 | FLAGS: | ||
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 | "\ | ||
121 | ra-cli-analysis-stats | ||
122 | |||
123 | USAGE: | ||
124 | ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH] | ||
125 | |||
126 | FLAGS: | ||
127 | -h, --help Prints help information | ||
128 | --memory-usage | ||
129 | -v, --verbose | ||
130 | -q, --quiet | ||
131 | |||
132 | OPTIONS: | ||
133 | -o <ONLY> | ||
134 | |||
135 | ARGS: | ||
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 | "\ | ||
180 | ra_cli-analysis-bench | ||
181 | |||
182 | USAGE: | ||
183 | ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH] | ||
184 | |||
185 | FLAGS: | ||
186 | -h, --help Prints help information | ||
187 | -v, --verbose | ||
188 | |||
189 | OPTIONS: | ||
190 | --complete <PATH:LINE:COLUMN> Compute completions at this location | ||
191 | --highlight <PATH> Hightlight this file | ||
192 | |||
193 | ARGS: | ||
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 | "\ | ||
218 | ra-cli | ||
219 | |||
220 | USAGE: | ||
221 | ra_cli <SUBCOMMAND> | ||
222 | |||
223 | FLAGS: | ||
224 | -h, --help Prints help information | ||
225 | |||
226 | SUBCOMMANDS: | ||
227 | analysis-bench | ||
228 | analysis-stats | ||
229 | highlight | ||
230 | parse | ||
231 | symbols" | ||
232 | ), | ||
144 | } | 233 | } |
145 | Ok(()) | 234 | Ok(()) |
146 | } | 235 | } |