mirror of
https://github.com/archtechx/todo-system.git
synced 2026-08-06 04:24:04 +00:00
cargo fmt + fix clippy warnings
This commit is contained in:
parent
6665e369bf
commit
16ec3a96e4
3 changed files with 694 additions and 483 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -1,14 +1,14 @@
|
||||||
use std::fs::canonicalize;
|
use std::fs::canonicalize;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::{Parser, ArgAction};
|
|
||||||
use crate::entries::Entry;
|
use crate::entries::Entry;
|
||||||
use crate::render::render_entries;
|
use crate::render::render_entries;
|
||||||
use crate::scan::{Stats, scan_dir, scan_todo_file, scan_readme_file, Exclude};
|
use crate::scan::{Exclude, Stats, scan_dir, scan_readme_file, scan_todo_file};
|
||||||
|
use clap::{ArgAction, Parser};
|
||||||
|
|
||||||
pub mod scan;
|
|
||||||
pub mod render;
|
|
||||||
pub mod entries;
|
pub mod entries;
|
||||||
|
pub mod render;
|
||||||
|
pub mod scan;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
|
|
@ -66,12 +66,12 @@ fn main() {
|
||||||
let mut path = root_dir.clone();
|
let mut path = root_dir.clone();
|
||||||
path.push(exclude);
|
path.push(exclude);
|
||||||
|
|
||||||
if path.exists() {
|
if path.exists()
|
||||||
if let Ok(realpath) = canonicalize(path) {
|
&& let Ok(realpath) = canonicalize(path)
|
||||||
|
{
|
||||||
excludes.push(Exclude::Path(realpath));
|
excludes.push(Exclude::Path(realpath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut todos_path = root_dir.clone();
|
let mut todos_path = root_dir.clone();
|
||||||
todos_path.push(&args.todos);
|
todos_path.push(&args.todos);
|
||||||
|
|
@ -100,9 +100,9 @@ fn main() {
|
||||||
if args.verbose > 0 {
|
if args.verbose > 0 {
|
||||||
eprint!("\n\n");
|
eprint!("\n\n");
|
||||||
stats.print();
|
stats.print();
|
||||||
eprintln!("Paths ({}): {:?}", &paths.len(), &paths);
|
eprintln!("Paths ({}): {:?}", paths.len(), paths);
|
||||||
eprintln!("Excludes ({}): {:?}", &excludes.len(), &excludes);
|
eprintln!("Excludes ({}): {:?}", excludes.len(), excludes);
|
||||||
eprintln!("todo.md: {:?}", &todos_path);
|
eprintln!("todo.md: {:?}", todos_path);
|
||||||
eprintln!("readme.md: {:?}", &readme_path);
|
eprintln!("readme.md: {:?}", readme_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::io::Write;
|
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::io::Write;
|
||||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||||
use std::cmp::Ordering::{Less, Equal, Greater};
|
|
||||||
|
|
||||||
use crate::entries::{Entry, EntryData};
|
use crate::entries::{Entry, EntryData};
|
||||||
|
|
||||||
|
|
@ -10,11 +10,20 @@ impl Entry {
|
||||||
let mut stdout = StandardStream::stdout(ColorChoice::Auto);
|
let mut stdout = StandardStream::stdout(ColorChoice::Auto);
|
||||||
write_ansi(&mut stdout, Color::Ansi256(243), "- [ ] ", false);
|
write_ansi(&mut stdout, Color::Ansi256(243), "- [ ] ", false);
|
||||||
|
|
||||||
let location = format!("{}:{}", self.location.file.to_string_lossy(), self.location.line);
|
let location = format!(
|
||||||
|
"{}:{}",
|
||||||
|
self.location.file.to_string_lossy(),
|
||||||
|
self.location.line
|
||||||
|
);
|
||||||
|
|
||||||
if !self.text.is_empty() {
|
if !self.text.is_empty() {
|
||||||
write_ansi(&mut stdout, Color::Blue, self.text.as_str(), true);
|
write_ansi(&mut stdout, Color::Blue, self.text.as_str(), true);
|
||||||
write_ansi(&mut stdout, Color::Ansi256(243), format!(" ({})", location).as_str(), false);
|
write_ansi(
|
||||||
|
&mut stdout,
|
||||||
|
Color::Ansi256(243),
|
||||||
|
format!(" ({})", location).as_str(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
write_ansi(&mut stdout, Color::Cyan, location.as_str(), true);
|
write_ansi(&mut stdout, Color::Cyan, location.as_str(), true);
|
||||||
}
|
}
|
||||||
|
|
@ -23,13 +32,10 @@ impl Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn write_ansi(stdout: &mut StandardStream, color: Color, text: &str, bold: bool) {
|
pub fn write_ansi(stdout: &mut StandardStream, color: Color, text: &str, bold: bool) {
|
||||||
stdout.set_color(
|
stdout
|
||||||
ColorSpec::new()
|
.set_color(ColorSpec::new().set_fg(Some(color)).set_bold(bold))
|
||||||
.set_fg(Some(color))
|
.unwrap();
|
||||||
.set_bold(bold)
|
|
||||||
).unwrap();
|
|
||||||
|
|
||||||
write!(stdout, "{text}").unwrap();
|
write!(stdout, "{text}").unwrap();
|
||||||
|
|
||||||
|
|
@ -46,13 +52,11 @@ pub fn render_entries(entries: Vec<Entry>) {
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
match entry.data {
|
match entry.data {
|
||||||
EntryData::Priority(priority) => {
|
EntryData::Priority(priority) => {
|
||||||
if ! priority_entries.contains_key(&priority) {
|
priority_entries.entry(priority).or_default();
|
||||||
priority_entries.insert(priority, vec![]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let vec = priority_entries.get_mut(&priority).unwrap();
|
let vec = priority_entries.get_mut(&priority).unwrap();
|
||||||
vec.push(entry);
|
vec.push(entry);
|
||||||
},
|
}
|
||||||
EntryData::Category(ref category) => {
|
EntryData::Category(ref category) => {
|
||||||
if !category_entries.contains_key(category) {
|
if !category_entries.contains_key(category) {
|
||||||
category_entries.insert(category.clone(), vec![]);
|
category_entries.insert(category.clone(), vec![]);
|
||||||
|
|
@ -60,7 +64,7 @@ pub fn render_entries(entries: Vec<Entry>) {
|
||||||
|
|
||||||
let vec = category_entries.get_mut(category).unwrap();
|
let vec = category_entries.get_mut(category).unwrap();
|
||||||
vec.push(entry);
|
vec.push(entry);
|
||||||
},
|
}
|
||||||
EntryData::Generic => {
|
EntryData::Generic => {
|
||||||
generic_entries.push(entry);
|
generic_entries.push(entry);
|
||||||
}
|
}
|
||||||
|
|
@ -81,15 +85,24 @@ pub fn render_entries(entries: Vec<Entry>) {
|
||||||
// todo0 -> 0
|
// todo0 -> 0
|
||||||
// todo00 -> -1
|
// todo00 -> -1
|
||||||
// Therefore: 'todo0' + priority.abs() * '0'
|
// Therefore: 'todo0' + priority.abs() * '0'
|
||||||
str.push_str(String::from_utf8(vec![b'0'; priority.unsigned_abs()]).unwrap().as_str());
|
str.push_str(
|
||||||
|
String::from_utf8(vec![b'0'; priority.unsigned_abs()])
|
||||||
|
.unwrap()
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
str
|
str
|
||||||
},
|
}
|
||||||
Equal => "todo0".to_string(),
|
Equal => "todo0".to_string(),
|
||||||
Greater => format!("todo{}", priority),
|
Greater => format!("todo{}", priority),
|
||||||
};
|
};
|
||||||
|
|
||||||
write_ansi(&mut stdout, Color::Red, format!("## {}", &priority_notation).as_str(), true);
|
write_ansi(
|
||||||
|
&mut stdout,
|
||||||
|
Color::Red,
|
||||||
|
format!("## {}", priority_notation).as_str(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
writeln!(stdout).unwrap();
|
writeln!(stdout).unwrap();
|
||||||
|
|
||||||
for item in priority_entries.get(priority).unwrap() {
|
for item in priority_entries.get(priority).unwrap() {
|
||||||
|
|
@ -103,7 +116,12 @@ pub fn render_entries(entries: Vec<Entry>) {
|
||||||
category_keys.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
category_keys.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||||
|
|
||||||
for category in category_keys {
|
for category in category_keys {
|
||||||
write_ansi(&mut stdout, Color::Green, format!("## {}", &category).as_str(), true);
|
write_ansi(
|
||||||
|
&mut stdout,
|
||||||
|
Color::Green,
|
||||||
|
format!("## {}", category).as_str(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
writeln!(stdout).unwrap();
|
writeln!(stdout).unwrap();
|
||||||
|
|
||||||
for item in category_entries.get(category).unwrap() {
|
for item in category_entries.get(category).unwrap() {
|
||||||
|
|
@ -113,7 +131,7 @@ pub fn render_entries(entries: Vec<Entry>) {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
if generic_entries.len() > 0 {
|
if !generic_entries.is_empty() {
|
||||||
write_ansi(&mut stdout, Color::White, "## Other", true);
|
write_ansi(&mut stdout, Color::White, "## Other", true);
|
||||||
writeln!(stdout).unwrap();
|
writeln!(stdout).unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
445
src/scan.rs
445
src/scan.rs
|
|
@ -1,7 +1,7 @@
|
||||||
use std::io;
|
use glob::Pattern;
|
||||||
use std::fs::{self, canonicalize};
|
use std::fs::{self, canonicalize};
|
||||||
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use glob::{Pattern};
|
|
||||||
|
|
||||||
const PRIORITY_CHARS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
const PRIORITY_CHARS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ impl Stats {
|
||||||
self.visited_file_count += 1;
|
self.visited_file_count += 1;
|
||||||
|
|
||||||
if self.verbosity >= 3 {
|
if self.verbosity >= 3 {
|
||||||
eprintln!("[INFO] Visited file: {}", &file);
|
eprintln!("[INFO] Visited file: {}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.verbosity >= 2 {
|
if self.verbosity >= 2 {
|
||||||
|
|
@ -57,7 +57,7 @@ impl Stats {
|
||||||
self.visited_folder_count += 1;
|
self.visited_folder_count += 1;
|
||||||
|
|
||||||
if self.verbosity >= 3 {
|
if self.verbosity >= 3 {
|
||||||
eprintln!("[INFO] Visited folder: {}", &folder);
|
eprintln!("[INFO] Visited folder: {}", folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.verbosity >= 2 {
|
if self.verbosity >= 2 {
|
||||||
|
|
@ -106,7 +106,9 @@ fn parse_priority(word: &str) -> Option<isize> {
|
||||||
|
|
||||||
/// Remove closing tags, comments, and whitespace
|
/// Remove closing tags, comments, and whitespace
|
||||||
fn clean_line<'a>(line: &'a str, delimiter_word: &str) -> &'a str {
|
fn clean_line<'a>(line: &'a str, delimiter_word: &str) -> &'a str {
|
||||||
line.split_once(delimiter_word).unwrap().1
|
line.split_once(delimiter_word)
|
||||||
|
.unwrap()
|
||||||
|
.1
|
||||||
.trim()
|
.trim()
|
||||||
.trim_end_matches("*/")
|
.trim_end_matches("*/")
|
||||||
.trim_end_matches("-->")
|
.trim_end_matches("-->")
|
||||||
|
|
@ -148,11 +150,11 @@ pub fn add_excludes_from_gitignore(base_dir: &PathBuf, excludes: &mut Vec<Exclud
|
||||||
pattern.push(line.trim_end_matches("*/").trim_matches('/'));
|
pattern.push(line.trim_end_matches("*/").trim_matches('/'));
|
||||||
|
|
||||||
if pattern.to_str().unwrap().contains('*') {
|
if pattern.to_str().unwrap().contains('*') {
|
||||||
if let Some(str) = pattern.to_str() {
|
if let Some(str) = pattern.to_str()
|
||||||
if let Ok(p) = Pattern::new(str) {
|
&& let Ok(p) = Pattern::new(str)
|
||||||
|
{
|
||||||
excludes.push(Exclude::Glob(p));
|
excludes.push(Exclude::Glob(p));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
excludes.push(Exclude::Path(pattern));
|
excludes.push(Exclude::Path(pattern));
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +190,12 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
|
||||||
|
|
||||||
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
|
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
|
||||||
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
|
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
|
||||||
if word.to_lowercase().trim_end_matches('"').trim_end_matches('\'') == "todo" {
|
if word
|
||||||
|
.to_lowercase()
|
||||||
|
.trim_end_matches('"')
|
||||||
|
.trim_end_matches('\'')
|
||||||
|
== "todo"
|
||||||
|
{
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
text: text.to_string(),
|
text: text.to_string(),
|
||||||
location: Location {
|
location: Location {
|
||||||
|
|
@ -214,8 +221,9 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
|
||||||
if let Some(priority) = parse_priority(word) {
|
&& let Some(priority) = parse_priority(word)
|
||||||
|
{
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
text: text.to_string(),
|
text: text.to_string(),
|
||||||
location: Location {
|
location: Location {
|
||||||
|
|
@ -224,7 +232,6 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
|
||||||
},
|
},
|
||||||
data: EntryData::Priority(priority),
|
data: EntryData::Priority(priority),
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +247,12 @@ pub fn scan_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scan_dir(dir: &Path, entries: &mut Vec<Entry>, excludes: &mut Vec<Exclude>, stats: &mut Stats) -> io::Result<()> {
|
pub fn scan_dir(
|
||||||
|
dir: &Path,
|
||||||
|
entries: &mut Vec<Entry>,
|
||||||
|
excludes: &mut Vec<Exclude>,
|
||||||
|
stats: &mut Stats,
|
||||||
|
) -> io::Result<()> {
|
||||||
let mut gitignore = dir.to_path_buf().clone();
|
let mut gitignore = dir.to_path_buf().clone();
|
||||||
gitignore.push(".gitignore");
|
gitignore.push(".gitignore");
|
||||||
|
|
||||||
|
|
@ -264,7 +276,14 @@ pub fn scan_dir(dir: &Path, entries: &mut Vec<Entry>, excludes: &mut Vec<Exclude
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
if path.components().last().unwrap().as_os_str().to_string_lossy().starts_with('.') {
|
if path
|
||||||
|
.components()
|
||||||
|
.next_back()
|
||||||
|
.unwrap()
|
||||||
|
.as_os_str()
|
||||||
|
.to_string_lossy()
|
||||||
|
.starts_with('.')
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,13 +325,14 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
|
||||||
// We need the line to start with # followed by spaces. So we cannot check just for '#'
|
// We need the line to start with # followed by spaces. So we cannot check just for '#'
|
||||||
// There's also no real need for any complex logic iterating over the line's characters,
|
// There's also no real need for any complex logic iterating over the line's characters,
|
||||||
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
|
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
|
||||||
if ! in_code_block && (false
|
if !in_code_block
|
||||||
|
&& (false
|
||||||
|| line.starts_with("# ")
|
|| line.starts_with("# ")
|
||||||
|| line.starts_with("## ")
|
|| line.starts_with("## ")
|
||||||
|| line.starts_with("### ")
|
|| line.starts_with("### ")
|
||||||
|| line.starts_with("#### ")
|
|| line.starts_with("#### ")
|
||||||
|| line.starts_with("##### ")
|
|| line.starts_with("##### "))
|
||||||
) {
|
{
|
||||||
current_category = Some(line.split_once("# ").unwrap().1);
|
current_category = Some(line.split_once("# ").unwrap().1);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -323,7 +343,12 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for word in line.split_whitespace() {
|
for word in line.split_whitespace() {
|
||||||
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
if word
|
||||||
|
.to_lowercase()
|
||||||
|
.trim_end_matches(':')
|
||||||
|
.starts_with("todo")
|
||||||
|
&& word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
|
||||||
|
{
|
||||||
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
text: clean_line(line, word).to_string(),
|
text: clean_line(line, word).to_string(),
|
||||||
|
|
@ -339,7 +364,11 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string();
|
let text = line
|
||||||
|
.trim_start()
|
||||||
|
.trim_start_matches("- [ ] ")
|
||||||
|
.trim_start_matches("- ")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
if let Some(category) = current_category {
|
if let Some(category) = current_category {
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
|
|
@ -388,15 +417,20 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
|
||||||
// We need the line to start with # followed by spaces. So we cannot check just for '#'
|
// We need the line to start with # followed by spaces. So we cannot check just for '#'
|
||||||
// There's also no real need for any complex logic iterating over the line's characters,
|
// There's also no real need for any complex logic iterating over the line's characters,
|
||||||
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
|
// we can just check reasonable heading hierarchy like this. Anything else is unlikely.
|
||||||
if ! in_code_block && (false
|
if !in_code_block
|
||||||
|
&& (false
|
||||||
|| line.starts_with("# ")
|
|| line.starts_with("# ")
|
||||||
|| line.starts_with("## ")
|
|| line.starts_with("## ")
|
||||||
|| line.starts_with("### ")
|
|| line.starts_with("### ")
|
||||||
|| line.starts_with("#### ")
|
|| line.starts_with("#### ")
|
||||||
|| line.starts_with("##### ")
|
|| line.starts_with("##### "))
|
||||||
) {
|
{
|
||||||
let section = line.split_once("# ").unwrap().1;
|
let section = line.split_once("# ").unwrap().1;
|
||||||
let cleaned_section = section.to_lowercase().trim_end_matches(':').trim().to_string();
|
let cleaned_section = section
|
||||||
|
.to_lowercase()
|
||||||
|
.trim_end_matches(':')
|
||||||
|
.trim()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
in_todo_section = cleaned_section == "todo" || cleaned_section == "todos";
|
in_todo_section = cleaned_section == "todo" || cleaned_section == "todos";
|
||||||
|
|
||||||
|
|
@ -412,7 +446,12 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
|
||||||
}
|
}
|
||||||
|
|
||||||
for word in line.split_whitespace() {
|
for word in line.split_whitespace() {
|
||||||
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
if word
|
||||||
|
.to_lowercase()
|
||||||
|
.trim_end_matches(':')
|
||||||
|
.starts_with("todo")
|
||||||
|
&& word.chars().any(|ch| PRIORITY_CHARS.contains(&ch))
|
||||||
|
{
|
||||||
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
text: clean_line(line, word).to_string(),
|
text: clean_line(line, word).to_string(),
|
||||||
|
|
@ -430,7 +469,11 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
|
||||||
|
|
||||||
// README.md can only have priority entries and generic entries
|
// README.md can only have priority entries and generic entries
|
||||||
entries.push(Entry {
|
entries.push(Entry {
|
||||||
text: line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(),
|
text: line
|
||||||
|
.trim_start()
|
||||||
|
.trim_start_matches("- [ ] ")
|
||||||
|
.trim_start_matches("- ")
|
||||||
|
.to_string(),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.to_path_buf(),
|
file: path.to_path_buf(),
|
||||||
line: line_num + 1,
|
line: line_num + 1,
|
||||||
|
|
@ -470,59 +513,77 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(6, entries.len());
|
assert_eq!(6, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("foo"),
|
text: String::from("foo"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 4,
|
line: 4,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("foo bar"),
|
text: String::from("foo bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 5,
|
line: 5,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("baz"),
|
text: String::from("baz"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 8,
|
line: 8,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("baz2"),
|
text: String::from("baz2"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 9,
|
line: 9,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("baz2 todo"),
|
text: String::from("baz2 todo"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 10,
|
line: 10,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("foo2"),
|
text: String::from("foo2"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 11,
|
line: 11,
|
||||||
}
|
}
|
||||||
}, entries[5]);
|
},
|
||||||
|
entries[5]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -548,70 +609,91 @@ mod tests {
|
||||||
|
|
||||||
scan_string(str.to_string(), path.clone(), &mut entries);
|
scan_string(str.to_string(), path.clone(), &mut entries);
|
||||||
|
|
||||||
assert_eq!(7, entries.len());
|
assert_eq!(8, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("foo")),
|
data: EntryData::Category(String::from("foo")),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 4,
|
line: 4,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("bar")),
|
data: EntryData::Category(String::from("bar")),
|
||||||
text: String::from("abc def"),
|
text: String::from("abc def"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 5,
|
line: 5,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("baz")),
|
data: EntryData::Category(String::from("baz")),
|
||||||
text: String::from("x y"),
|
text: String::from("x y"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 7,
|
line: 7,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("baz2")),
|
data: EntryData::Category(String::from("baz2")),
|
||||||
text: String::from("a"),
|
text: String::from("a"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 9,
|
line: 9,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("baz3")),
|
data: EntryData::Category(String::from("baz3")),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 10,
|
line: 10,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("baz3")),
|
data: EntryData::Category(String::from("baz3")),
|
||||||
text: String::from("b"),
|
text: String::from("b"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 11,
|
line: 11,
|
||||||
}
|
}
|
||||||
}, entries[5]);
|
},
|
||||||
|
entries[5]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("baz3")),
|
data: EntryData::Category(String::from("baz3")),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 12,
|
line: 12,
|
||||||
}
|
}
|
||||||
}, entries[6]);
|
},
|
||||||
|
entries[6]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Entry {
|
Entry {
|
||||||
|
|
@ -653,95 +735,125 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(10, entries.len());
|
assert_eq!(10, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-1),
|
data: EntryData::Priority(-1),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 4,
|
line: 4,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-2),
|
data: EntryData::Priority(-2),
|
||||||
text: String::from("abc"),
|
text: String::from("abc"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 5,
|
line: 5,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(0),
|
data: EntryData::Priority(0),
|
||||||
text: String::from("abc def"),
|
text: String::from("abc def"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 6,
|
line: 6,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(1),
|
data: EntryData::Priority(1),
|
||||||
text: String::from("foo"),
|
text: String::from("foo"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 7,
|
line: 7,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(1),
|
data: EntryData::Priority(1),
|
||||||
text: String::from("x y"),
|
text: String::from("x y"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 9,
|
line: 9,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(0),
|
data: EntryData::Priority(0),
|
||||||
text: String::from("bar"),
|
text: String::from("bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 11,
|
line: 11,
|
||||||
}
|
}
|
||||||
}, entries[5]);
|
},
|
||||||
|
entries[5]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(1),
|
data: EntryData::Priority(1),
|
||||||
text: String::from("a"),
|
text: String::from("a"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 12,
|
line: 12,
|
||||||
}
|
}
|
||||||
}, entries[6]);
|
},
|
||||||
|
entries[6]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(2),
|
data: EntryData::Priority(2),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 13,
|
line: 13,
|
||||||
}
|
}
|
||||||
}, entries[7]);
|
},
|
||||||
|
entries[7]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(3),
|
data: EntryData::Priority(3),
|
||||||
text: String::from("b"),
|
text: String::from("b"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 14,
|
line: 14,
|
||||||
}
|
}
|
||||||
}, entries[8]);
|
},
|
||||||
|
entries[8]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(4),
|
data: EntryData::Priority(4),
|
||||||
text: String::from("b"),
|
text: String::from("b"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 15,
|
line: 15,
|
||||||
}
|
}
|
||||||
}, entries[9]);
|
},
|
||||||
|
entries[9]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -756,95 +868,125 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(10, entries.len());
|
assert_eq!(10, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("types")),
|
data: EntryData::Category(String::from("types")),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 1,
|
line: 1,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("types")),
|
data: EntryData::Category(String::from("types")),
|
||||||
text: String::from("add types"),
|
text: String::from("add types"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 5,
|
line: 5,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-2),
|
data: EntryData::Priority(-2),
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 10,
|
line: 10,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-1),
|
data: EntryData::Priority(-1),
|
||||||
text: String::from("add return typehint"),
|
text: String::from("add return typehint"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 14,
|
line: 14,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(0),
|
data: EntryData::Priority(0),
|
||||||
text: String::from("add name typehint"),
|
text: String::from("add name typehint"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 19,
|
line: 19,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(1),
|
data: EntryData::Priority(1),
|
||||||
text: String::from("add return typehint"),
|
text: String::from("add return typehint"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 23,
|
line: 23,
|
||||||
}
|
}
|
||||||
}, entries[5]);
|
},
|
||||||
|
entries[5]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(2),
|
data: EntryData::Priority(2),
|
||||||
text: String::from("add return typehint"),
|
text: String::from("add return typehint"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 27,
|
line: 27,
|
||||||
}
|
}
|
||||||
}, entries[6]);
|
},
|
||||||
|
entries[6]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from(""),
|
text: String::from(""),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 31,
|
line: 31,
|
||||||
}
|
}
|
||||||
}, entries[7]);
|
},
|
||||||
|
entries[7]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("generic todo 2"),
|
text: String::from("generic todo 2"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 33,
|
line: 33,
|
||||||
}
|
}
|
||||||
}, entries[8]);
|
},
|
||||||
|
entries[8]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("generic todo 3"),
|
text: String::from("generic todo 3"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 34,
|
line: 34,
|
||||||
}
|
}
|
||||||
}, entries[9]);
|
},
|
||||||
|
entries[9]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -859,41 +1001,53 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(4, entries.len());
|
assert_eq!(4, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("todo!(\"generic\");"),
|
text: String::from("todo!(\"generic\");"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 3,
|
line: 3,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("todo!();"),
|
text: String::from("todo!();"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 4,
|
line: 4,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("todo!(\"@foo not category\");"),
|
text: String::from("todo!(\"@foo not category\");"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 5,
|
line: 5,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("todo!(\"00 not priority\");"),
|
text: String::from("todo!(\"00 not priority\");"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 6,
|
line: 6,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -908,77 +1062,101 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(8, entries.len());
|
assert_eq!(8, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("generic foo"),
|
text: String::from("generic foo"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 1,
|
line: 1,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("generic bar"),
|
text: String::from("generic bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 2,
|
line: 2,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-1),
|
data: EntryData::Priority(-1),
|
||||||
text: String::from("priority bar"),
|
text: String::from("priority bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 3,
|
line: 3,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(0),
|
data: EntryData::Priority(0),
|
||||||
text: String::from("a"),
|
text: String::from("a"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 6,
|
line: 6,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("High priority")),
|
data: EntryData::Category(String::from("High priority")),
|
||||||
text: String::from("foo"),
|
text: String::from("foo"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 7,
|
line: 7,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("High priority")),
|
data: EntryData::Category(String::from("High priority")),
|
||||||
text: String::from("bar"),
|
text: String::from("bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 8,
|
line: 8,
|
||||||
}
|
}
|
||||||
}, entries[5]);
|
},
|
||||||
|
entries[5]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("Responsivity")),
|
data: EntryData::Category(String::from("Responsivity")),
|
||||||
text: String::from("abc"),
|
text: String::from("abc"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 11,
|
line: 11,
|
||||||
}
|
}
|
||||||
}, entries[6]);
|
},
|
||||||
|
entries[6]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Category(String::from("Responsivity")),
|
data: EntryData::Category(String::from("Responsivity")),
|
||||||
text: String::from("def"),
|
text: String::from("def"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 12,
|
line: 12,
|
||||||
}
|
}
|
||||||
}, entries[7]);
|
},
|
||||||
|
entries[7]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -993,49 +1171,64 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(5, entries.len());
|
assert_eq!(5, entries.len());
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("abc"),
|
text: String::from("abc"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 19,
|
line: 19,
|
||||||
}
|
}
|
||||||
}, entries[0]);
|
},
|
||||||
|
entries[0]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(0),
|
data: EntryData::Priority(0),
|
||||||
text: String::from("def"),
|
text: String::from("def"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 20,
|
line: 20,
|
||||||
}
|
}
|
||||||
}, entries[1]);
|
},
|
||||||
|
entries[1]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Priority(-1),
|
data: EntryData::Priority(-1),
|
||||||
text: String::from("ghi"),
|
text: String::from("ghi"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 21,
|
line: 21,
|
||||||
}
|
}
|
||||||
}, entries[2]);
|
},
|
||||||
|
entries[2]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("bar"),
|
text: String::from("bar"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 22,
|
line: 22,
|
||||||
}
|
}
|
||||||
}, entries[3]);
|
},
|
||||||
|
entries[3]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(Entry {
|
assert_eq!(
|
||||||
|
Entry {
|
||||||
data: EntryData::Generic,
|
data: EntryData::Generic,
|
||||||
text: String::from("baz"),
|
text: String::from("baz"),
|
||||||
location: Location {
|
location: Location {
|
||||||
file: path.clone(),
|
file: path.clone(),
|
||||||
line: 23,
|
line: 23,
|
||||||
}
|
}
|
||||||
}, entries[4]);
|
},
|
||||||
|
entries[4]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue