diff options
Diffstat (limited to 'tools/src/bin')
-rw-r--r-- | tools/src/bin/main.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tools/src/bin/main.rs b/tools/src/bin/main.rs index 6a9793fff..125930127 100644 --- a/tools/src/bin/main.rs +++ b/tools/src/bin/main.rs | |||
@@ -1,18 +1,14 @@ | |||
1 | extern crate clap; | 1 | extern crate clap; |
2 | #[macro_use] | 2 | #[macro_use] |
3 | extern crate failure; | 3 | extern crate failure; |
4 | extern crate tera; | 4 | extern crate itertools; |
5 | extern crate ron; | 5 | extern crate ron; |
6 | extern crate tera; | ||
6 | extern crate walkdir; | 7 | extern crate walkdir; |
7 | extern crate itertools; | ||
8 | 8 | ||
9 | use std::{ | ||
10 | fs, | ||
11 | path::{Path}, | ||
12 | collections::HashSet, | ||
13 | }; | ||
14 | use clap::{App, Arg, SubCommand}; | 9 | use clap::{App, Arg, SubCommand}; |
15 | use itertools::Itertools; | 10 | use itertools::Itertools; |
11 | use std::{collections::HashSet, fs, path::Path}; | ||
16 | 12 | ||
17 | type Result<T> = ::std::result::Result<T, failure::Error>; | 13 | type Result<T> = ::std::result::Result<T, failure::Error>; |
18 | 14 | ||
@@ -29,7 +25,7 @@ fn main() -> Result<()> { | |||
29 | Arg::with_name("verify") | 25 | Arg::with_name("verify") |
30 | .long("--verify") | 26 | .long("--verify") |
31 | .help("Verify that generated code is up-to-date") | 27 | .help("Verify that generated code is up-to-date") |
32 | .global(true) | 28 | .global(true), |
33 | ) | 29 | ) |
34 | .subcommand(SubCommand::with_name("gen-kinds")) | 30 | .subcommand(SubCommand::with_name("gen-kinds")) |
35 | .subcommand(SubCommand::with_name("gen-tests")) | 31 | .subcommand(SubCommand::with_name("gen-tests")) |
@@ -66,9 +62,8 @@ fn update(path: &Path, contents: &str, verify: bool) -> Result<()> { | |||
66 | fn get_kinds() -> Result<String> { | 62 | fn get_kinds() -> Result<String> { |
67 | let grammar = grammar()?; | 63 | let grammar = grammar()?; |
68 | let template = fs::read_to_string(SYNTAX_KINDS_TEMPLATE)?; | 64 | let template = fs::read_to_string(SYNTAX_KINDS_TEMPLATE)?; |
69 | let ret = tera::Tera::one_off(&template, &grammar, false).map_err(|e| { | 65 | let ret = tera::Tera::one_off(&template, &grammar, false) |
70 | format_err!("template error: {}", e) | 66 | .map_err(|e| format_err!("template error: {}", e))?; |
71 | })?; | ||
72 | Ok(ret) | 67 | Ok(ret) |
73 | } | 68 | } |
74 | 69 | ||
@@ -142,7 +137,8 @@ fn tests_from_dir(dir: &Path) -> Result<HashSet<Test>> { | |||
142 | fn collect_tests(s: &str) -> Vec<Test> { | 137 | fn collect_tests(s: &str) -> Vec<Test> { |
143 | let mut res = vec![]; | 138 | let mut res = vec![]; |
144 | let prefix = "// "; | 139 | let prefix = "// "; |
145 | let comment_blocks = s.lines() | 140 | let comment_blocks = s |
141 | .lines() | ||
146 | .map(str::trim_left) | 142 | .map(str::trim_left) |
147 | .group_by(|line| line.starts_with(prefix)); | 143 | .group_by(|line| line.starts_with(prefix)); |
148 | 144 | ||
@@ -181,4 +177,3 @@ fn existing_tests(dir: &Path) -> Result<HashSet<Test>> { | |||
181 | } | 177 | } |
182 | Ok(res) | 178 | Ok(res) |
183 | } | 179 | } |
184 | |||