diff options
Diffstat (limited to 'crates/ra_cli/src/main.rs')
-rw-r--r-- | crates/ra_cli/src/main.rs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 6a0e447b9..749317475 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -133,22 +133,15 @@ fn main() -> Result<()> { | |||
133 | let verbose = matches.contains(["-v", "--verbose"]); | 133 | let verbose = matches.contains(["-v", "--verbose"]); |
134 | let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default(); | 134 | let path: String = matches.opt_value_from_str("--path")?.unwrap_or_default(); |
135 | let highlight_path = matches.opt_value_from_str("--highlight")?; | 135 | let highlight_path = matches.opt_value_from_str("--highlight")?; |
136 | let complete_path = matches.opt_value_from_str("--complete")?; | 136 | let complete_path: Option<String> = matches.opt_value_from_str("--complete")?; |
137 | if highlight_path.is_some() && complete_path.is_some() { | 137 | if highlight_path.is_some() && complete_path.is_some() { |
138 | panic!("either --highlight or --complete must be set, not both") | 138 | panic!("either --highlight or --complete must be set, not both") |
139 | } | 139 | } |
140 | let op = if let Some(path) = highlight_path { | 140 | let op = if let Some(path) = highlight_path { |
141 | let path: String = path; | 141 | let path: String = path; |
142 | analysis_bench::Op::Highlight { path: path.into() } | 142 | analysis_bench::Op::Highlight { path: path.into() } |
143 | } else if let Some(path_line_col) = complete_path { | 143 | } else if let Some(position) = complete_path { |
144 | let path_line_col: String = path_line_col; | 144 | analysis_bench::Op::Complete(position.parse()?) |
145 | let (path_line, column) = rsplit_at_char(path_line_col.as_str(), ':')?; | ||
146 | let (path, line) = rsplit_at_char(path_line, ':')?; | ||
147 | analysis_bench::Op::Complete { | ||
148 | path: path.into(), | ||
149 | line: line.parse()?, | ||
150 | column: column.parse()?, | ||
151 | } | ||
152 | } else { | 145 | } else { |
153 | panic!("either --highlight or --complete must be set") | 146 | panic!("either --highlight or --complete must be set") |
154 | }; | 147 | }; |
@@ -183,8 +176,3 @@ fn read_stdin() -> Result<String> { | |||
183 | std::io::stdin().read_to_string(&mut buff)?; | 176 | std::io::stdin().read_to_string(&mut buff)?; |
184 | Ok(buff) | 177 | Ok(buff) |
185 | } | 178 | } |
186 | |||
187 | fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> { | ||
188 | let idx = s.rfind(':').ok_or_else(|| format!("no `{}` in {}", c, s))?; | ||
189 | Ok((&s[..idx], &s[idx + 1..])) | ||
190 | } | ||