style: code style
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -54,7 +54,6 @@ fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
parsers.push(Parser::new(String::from("//fix"), Box::from(|x : Vec<char>| x.last().unwrap() == &'\n')));
|
parsers.push(Parser::new(String::from("//fix"), Box::from(|x : Vec<char>| x.last().unwrap() == &'\n')));
|
||||||
|
|
||||||
|
|
||||||
//loop on every file within the current dir
|
//loop on every file within the current dir
|
||||||
for entry in match glob(&path) {
|
for entry in match glob(&path) {
|
||||||
Ok(entry) => entry,
|
Ok(entry) => entry,
|
||||||
@@ -84,23 +83,22 @@ fn main() -> std::io::Result<()> {
|
|||||||
let mut path = String::from(dirs::home_dir().unwrap().to_str().unwrap());
|
let mut path = String::from(dirs::home_dir().unwrap().to_str().unwrap());
|
||||||
path.push_str("/.cargo/todo_config");
|
path.push_str("/.cargo/todo_config");
|
||||||
// println!("{}",path);
|
// println!("{}",path);
|
||||||
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path> {
|
||||||
where P: AsRef<Path>, {
|
let file = match File::open(&filename) {
|
||||||
let file = match File::open(&filename){
|
Ok(line) => line,
|
||||||
Ok(line) => line,
|
Err(_) => {
|
||||||
Err(_) => {
|
println!("{}", "File '~/.cargo/todo_config' not found, creating it".red());
|
||||||
println!("{}", "File '~/.cargo/todo_config' not found, creating it".red());
|
let mut f = OpenOptions::new().write(true).read(true).create(true).open(&filename).unwrap();
|
||||||
let mut f = OpenOptions::new().write(true).read(true).create(true).open(&filename).unwrap();
|
f.write_all(b"^s*//s*todo\\b\n").unwrap();
|
||||||
f.write_all(b"^s*//s*todo\\b\n").unwrap();
|
f.write_all(b"^s*//s*fix\\b\n").unwrap();
|
||||||
f.write_all(b"^s*//s*fix\\b\n").unwrap();
|
f.write_all(b"^s*//s*fixme\\b\n").unwrap();
|
||||||
f.write_all(b"^s*//s*fixme\\b\n").unwrap();
|
return read_lines(filename);
|
||||||
return read_lines(filename);
|
}
|
||||||
}
|
};
|
||||||
};
|
Ok(io::BufReader::new(file).lines())
|
||||||
Ok(io::BufReader::new(file).lines())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut regex = Vec::new();
|
let mut regex = vec![];
|
||||||
for line in read_lines(path).unwrap() {
|
for line in read_lines(path).unwrap() {
|
||||||
let line = line.unwrap();
|
let line = line.unwrap();
|
||||||
regex.push(line);
|
regex.push(line);
|
||||||
@@ -115,14 +113,16 @@ fn main() -> std::io::Result<()> {
|
|||||||
println!("Couldn't access files. Error {}", e);
|
println!("Couldn't access files. Error {}", e);
|
||||||
Err(e).unwrap()
|
Err(e).unwrap()
|
||||||
}
|
}
|
||||||
} {
|
}
|
||||||
|
|
||||||
|
{
|
||||||
let path = entry.unwrap();
|
let path = entry.unwrap();
|
||||||
let path = Path::new(&path).strip_prefix(env::current_dir().unwrap().to_str().unwrap()).unwrap();
|
let path = Path::new(&path).strip_prefix(env::current_dir().unwrap().to_str().unwrap()).unwrap();
|
||||||
// println!("{}", path.to_str().unwrap());
|
// println!("{}", path.to_str().unwrap());
|
||||||
if !path.starts_with("target/") {
|
if !path.starts_with("target/") {
|
||||||
let path = path.to_str().unwrap();
|
let path = path.to_str().unwrap();
|
||||||
|
|
||||||
if matches.occurrences_of("verbose") == 0 || matches.occurrences_of("verbose") == 2{
|
if matches.occurrences_of("verbose") == 0 || matches.occurrences_of("verbose") == 2 {
|
||||||
match regex_parser(path, regex.clone(), 2){
|
match regex_parser(path, regex.clone(), 2){
|
||||||
Ok(mut t) => {
|
Ok(mut t) => {
|
||||||
tokens.append(&mut t);
|
tokens.append(&mut t);
|
||||||
@@ -188,7 +188,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
for i in tokens{
|
for i in tokens{
|
||||||
// println!("{}", i);
|
// println!("{}", i);
|
||||||
for y in &filters {
|
for y in &filters {
|
||||||
if i.member.clone().is_some() && i.member.clone().unwrap() == *y.to_string(){
|
if i.member.clone().is_some() && i.member.clone().unwrap() == *y.to_string() {
|
||||||
println!("pushing");
|
println!("pushing");
|
||||||
new_tokens.push(i.clone());
|
new_tokens.push(i.clone());
|
||||||
break;
|
break;
|
||||||
@@ -221,7 +221,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
if i.keyword == excludes[y] {
|
if i.keyword == excludes[y] {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if y == excludes.len() -1{
|
else if y == excludes.len() -1 {
|
||||||
new_tokens.push(i.clone());
|
new_tokens.push(i.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user