aboutsummaryrefslogtreecommitdiff
path: root/tools/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/bin')
-rw-r--r--tools/src/bin/main.rs21
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 @@
1extern crate clap; 1extern crate clap;
2#[macro_use] 2#[macro_use]
3extern crate failure; 3extern crate failure;
4extern crate tera; 4extern crate itertools;
5extern crate ron; 5extern crate ron;
6extern crate tera;
6extern crate walkdir; 7extern crate walkdir;
7extern crate itertools;
8 8
9use std::{
10 fs,
11 path::{Path},
12 collections::HashSet,
13};
14use clap::{App, Arg, SubCommand}; 9use clap::{App, Arg, SubCommand};
15use itertools::Itertools; 10use itertools::Itertools;
11use std::{collections::HashSet, fs, path::Path};
16 12
17type Result<T> = ::std::result::Result<T, failure::Error>; 13type 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<()> {
66fn get_kinds() -> Result<String> { 62fn 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>> {
142fn collect_tests(s: &str) -> Vec<Test> { 137fn 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