Skip to content

Commit

Permalink
simplifying output and --check code now that filter is in TodoR
Browse files Browse the repository at this point in the history
  • Loading branch information
lavifb committed Jan 2, 2019
1 parent b637b48 commit b91ff37
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/bin/todor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ fn run(matches: &ArgMatches) -> Result<i32, Error> {
todor.set_todo_filter(pred);
}

let check = matches.is_present("CHECK");
if matches.is_present("DELETE_MODE") {
run_delete(&mut todor)?;
} else if let Some(format) = matches.value_of("FORMAT") {
Expand All @@ -136,14 +135,12 @@ fn run(matches: &ArgMatches) -> Result<i32, Error> {
};

todor.print_formatted_todos(&report_format)?;
if check && todor.num_todos() > 0 {
return Ok(1);
}
} else {
todor.print_todos();
if check && todor.num_todos() > 0 {
return Ok(1);
}
}

if matches.is_present("CHECK") && todor.num_todos() > 0 {
return Ok(1);
}

Ok(0)
Expand Down
1 change: 0 additions & 1 deletion src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ fn parse_style_color(color: &str) -> Result<Style, Error> {
Ok(colored_style)
}

// TODO: modifiers for Fixed() colors
/// Parses modifier str to modify a Style and return the result
fn parse_style_modifier(unmodified_style: Style, modifier: &str) -> Result<Style, Error> {
let style = match modifier.to_uppercase().as_str() {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,10 @@ struct TodoRConfig {
}

/// Parser for finding TODOs in comments and storing them on a per-file basis.
// #[derive(Debug, Clone)]
pub struct TodoR<'a> {
config: TodoRConfig,
todo_files: Vec<TodoFile>,
ext_to_regexs: FnvHashMap<String, Vec<Regex>>,
// TODO: set filter for todor
filter: Box<'a + Fn(&&Todo) -> bool>,
}

Expand Down Expand Up @@ -298,8 +296,9 @@ impl<'a> TodoR<'a> {
}
}

/// Sets TodoR to only ouput TODOs that satisfy pred
/// Sets TodoR to only output TODOs that satisfy pred
pub fn set_todo_filter<P: 'a + Fn(&&Todo) -> bool>(&mut self, pred: P) {
debug!("setting filter for TODO output");
self.filter = Box::new(pred);
}

Expand Down Expand Up @@ -398,6 +397,7 @@ impl<'a> TodoR<'a> {

let file = File::open(filepath)?;
let mut file_reader = BufReader::new(file);
// TODO: use filter when parsing TODOs
todo_file.set_todos(parse_content(&mut file_reader, &parser_regexs)?);

debug!(
Expand Down
2 changes: 1 addition & 1 deletion src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl PrintTodos<'_> {
}
}

// TODO: add more output formats
// MAYB: add more output formats
/// Enum holding the different supported output formats.
pub enum ReportFormat {
Json,
Expand Down

0 comments on commit b91ff37

Please sign in to comment.