This commit is contained in:
parent
cf67463016
commit
b4552c7304
10 changed files with 43 additions and 77 deletions
|
@ -1,22 +0,0 @@
|
|||
use super::Marker;
|
||||
|
||||
//
|
||||
#[derive(Debug, Default)]
|
||||
pub struct FoundMarkers {
|
||||
markers: Vec<Marker>,
|
||||
}
|
||||
impl FoundMarkers {
|
||||
pub fn add_marker(&mut self, marker: Marker) {
|
||||
self.markers.push(marker);
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for FoundMarkers {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
for marker in self.markers.iter() {
|
||||
// if !matches!(marker, Marker::Unmarked) {
|
||||
write!(f, "{marker}")?;
|
||||
// }
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
//
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::Marker;
|
||||
|
||||
use bon::Builder;
|
||||
|
||||
#[derive(Debug, Builder)]
|
||||
pub struct IssueMarker {
|
||||
/// The marker
|
||||
marker: Marker,
|
||||
|
||||
/// The issue number
|
||||
issue: usize,
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
//
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::model::Line;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Marker {
|
||||
Unmarked,
|
||||
Invalid(Line),
|
||||
Valid(Line, String),
|
||||
}
|
||||
impl std::fmt::Display for Marker {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Marker::Unmarked => Ok(()),
|
||||
Marker::Invalid(line) => write!(f, "- Invalid: {line}"),
|
||||
Marker::Valid(line, _) => write!(f, "- Valid : {line}"),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,41 @@
|
|||
//
|
||||
mod found;
|
||||
mod issue;
|
||||
mod marker;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use found::FoundMarkers;
|
||||
pub use marker::Marker;
|
||||
use crate::model::Line;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Marker {
|
||||
Unmarked,
|
||||
Invalid(Line),
|
||||
#[allow(dead_code)]
|
||||
Valid(Line, String),
|
||||
}
|
||||
impl std::fmt::Display for Marker {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Marker::Unmarked => Ok(()),
|
||||
Marker::Invalid(line) => write!(f, "- Invalid: {line}"),
|
||||
Marker::Valid(line, _) => write!(f, "- Valid : {line}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Markers {
|
||||
markers: Vec<Marker>,
|
||||
}
|
||||
impl Markers {
|
||||
pub fn add_marker(&mut self, marker: Marker) {
|
||||
self.markers.push(marker);
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Markers {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
for marker in self.markers.iter() {
|
||||
write!(f, "{marker}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::model::Line;
|
||||
|
||||
//
|
||||
use super::*;
|
||||
use crate::model::{markers::Markers, Line};
|
||||
|
||||
#[test]
|
||||
fn found_when_displayed() -> anyhow::Result<()> {
|
||||
|
@ -10,7 +8,7 @@ fn found_when_displayed() -> anyhow::Result<()> {
|
|||
let file = fs.base().join("file-name");
|
||||
let relative = file.strip_prefix(fs.base())?.to_path_buf();
|
||||
|
||||
let mut found = FoundMarkers::default();
|
||||
let mut found = Markers::default();
|
||||
|
||||
let marker_unmarked = Line::builder()
|
||||
.file(file.clone())
|
|
@ -1,6 +0,0 @@
|
|||
//
|
||||
use super::*;
|
||||
|
||||
mod found;
|
||||
mod issue;
|
||||
mod marker;
|
|
@ -8,5 +8,5 @@ mod tests;
|
|||
|
||||
pub use config::Config;
|
||||
pub use line::Line;
|
||||
pub use markers::FoundMarkers;
|
||||
pub use markers::Marker;
|
||||
pub use markers::Markers;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
//
|
||||
use std::path::Path;
|
||||
|
||||
use crate::model::{Config, FoundMarkers, Line, Marker};
|
||||
use crate::model::{Config, Line, Marker, Markers};
|
||||
use anyhow::Result;
|
||||
use ignore::Walk;
|
||||
|
||||
pub fn find_markers(config: &Config) -> Result<FoundMarkers, anyhow::Error> {
|
||||
let mut markers = FoundMarkers::default();
|
||||
pub fn find_markers(config: &Config) -> Result<Markers, anyhow::Error> {
|
||||
let mut markers = Markers::default();
|
||||
for file in Walk::new(config.fs().base()).flatten() {
|
||||
let path = file.path();
|
||||
if config.fs().path_is_file(path)? {
|
||||
|
@ -16,7 +16,7 @@ pub fn find_markers(config: &Config) -> Result<FoundMarkers, anyhow::Error> {
|
|||
Ok(markers)
|
||||
}
|
||||
|
||||
fn scan_file(file: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> {
|
||||
fn scan_file(file: &Path, config: &Config, found_markers: &mut Markers) -> Result<()> {
|
||||
let relative_path = file.strip_prefix(config.fs().base())?.to_path_buf();
|
||||
config
|
||||
.fs()
|
||||
|
|
Loading…
Reference in a new issue