style: code style
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -3,7 +3,7 @@ use std::fs::OpenOptions;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use std::io::{ self, BufRead };
|
||||
use std::io::{ self, Lines, BufRead, BufReader };
|
||||
use std::collections::HashSet;
|
||||
use glob::glob;
|
||||
use colored::Colorize;
|
||||
@@ -33,7 +33,7 @@ fn main() -> std::io::Result<()> {
|
||||
.get_matches();
|
||||
|
||||
if let Some(_matches) = matches.subcommand_matches("legacy") {
|
||||
let mut parsers : Vec<Parser> = vec!();
|
||||
let mut parsers : Vec<Parser> = vec![];
|
||||
|
||||
let mut path = String::from(env::current_dir().unwrap().to_str().unwrap());
|
||||
path.push_str("/**/*.rs");
|
||||
@@ -41,17 +41,17 @@ fn main() -> std::io::Result<()> {
|
||||
//we add a parser looking for the //todo keyword
|
||||
parsers.push(Parser::new(String::from("//todo"), Box::from(|x : Vec<char>| x.last().unwrap() == &'\n')));
|
||||
//we add a parser looking for the todo!() token
|
||||
let _todo_macro_callback = Box::from(|mut text : String, line : usize, file : &str| {
|
||||
let todo_macro_callback = Box::from(|mut text : String, line : usize, file : &str| {
|
||||
text.retain(|c| c != '\"');
|
||||
println!("{} {} {} {} : {}",file,"TODO".green() ,"Line ".green(), line.to_string().green(), text.blue());
|
||||
});
|
||||
parsers.push(Parser::new_callback(String::from("todo!("), Box::from(|x : Vec<char>| x.last().unwrap() == &')'), _todo_macro_callback));
|
||||
parsers.push(Parser::new_callback(String::from("todo!("), Box::from(|x : Vec<char>| x.last().unwrap() == &')'), todo_macro_callback));
|
||||
|
||||
//support for unimplemented
|
||||
let _unimplemented_macro_callback = Box::from(|text : String, line : usize, file : &str| {
|
||||
println!("{} {} {} {} : {}{}{} ",file,"TODO".green() ,"Line ".green(), line.to_string().green(), "unimplemented!(".blue(), text.magenta(), ")".blue());
|
||||
let unimplemented_macro_callback = Box::from(|text : String, line : usize, file : &str| {
|
||||
println!("{} {} {} {} : {}{}{} ", file, "TODO".green(), "Line ".green(), line.to_string().green(), "unimplemented!(".blue(), text.magenta(), ")".blue());
|
||||
});
|
||||
parsers.push(Parser::new_callback(String::from("unimplemented!("), Box::from(|x : Vec<char>| x.last().unwrap() == &')'), _unimplemented_macro_callback));
|
||||
parsers.push(Parser::new_callback(String::from("unimplemented!("), Box::from(|x : Vec<char>| x.last().unwrap() == &')'), unimplemented_macro_callback));
|
||||
|
||||
parsers.push(Parser::new(String::from("//fix"), Box::from(|x : Vec<char>| x.last().unwrap() == &'\n')));
|
||||
|
||||
@@ -84,7 +84,7 @@ fn main() -> std::io::Result<()> {
|
||||
let mut path = String::from(dirs::home_dir().unwrap().to_str().unwrap());
|
||||
path.push_str("/.cargo/todo_config");
|
||||
// println!("{}",path);
|
||||
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path> {
|
||||
fn read_lines<P>(filename: P) -> io::Result<Lines<BufReader<File>>> where P: AsRef<Path> {
|
||||
let file = match File::open(&filename) {
|
||||
Ok(line) => line,
|
||||
Err(_) => {
|
||||
@@ -96,7 +96,7 @@ fn main() -> std::io::Result<()> {
|
||||
return read_lines(filename);
|
||||
}
|
||||
};
|
||||
Ok(io::BufReader::new(file).lines())
|
||||
Ok(BufReader::new(file).lines())
|
||||
}
|
||||
|
||||
let mut regex = vec![];
|
||||
|
||||
Reference in New Issue
Block a user