mod debounce;
mod state;
mod watcher;
#[cfg(feature = "notifications")]
mod notifications;
pub use debounce::Debouncer;
pub use state::{FileStatus, WatchState};
pub use watcher::{FileWatcher, WatchEvent, WatchEventKind};
#[cfg(feature = "notifications")]
pub use notifications::notify_issues;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct WatchConfig {
pub paths: Vec<PathBuf>,
pub check_only: bool,
pub format_only: bool,
pub debounce_ms: u64,
pub notify: bool,
pub no_tui: bool,
pub clear: bool,
pub verbose: bool,
pub languages: Vec<crate::Language>,
pub exclude_patterns: Vec<String>,
}
impl Default for WatchConfig {
fn default() -> Self {
Self {
paths: vec![PathBuf::from(".")],
check_only: false,
format_only: false,
debounce_ms: 300,
notify: false,
no_tui: false,
clear: false,
verbose: false,
languages: Vec::new(),
exclude_patterns: Vec::new(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct WatchResult {
pub files_checked: usize,
pub error_count: usize,
pub warning_count: usize,
pub info_count: usize,
pub files_formatted: usize,
pub duration_ms: u64,
pub is_clean: bool,
}
impl WatchResult {
pub fn from_run_result(result: &crate::utils::types::RunResult) -> Self {
let mut error_count = 0;
let mut warning_count = 0;
let mut info_count = 0;
for issue in &result.issues {
match issue.severity {
crate::Severity::Error => error_count += 1,
crate::Severity::Warning => warning_count += 1,
crate::Severity::Info => info_count += 1,
}
}
Self {
files_checked: result.total_files,
error_count,
warning_count,
info_count,
files_formatted: result.format_results.len(),
duration_ms: result.duration_ms,
is_clean: result.issues.is_empty(),
}
}
pub fn total_issues(&self) -> usize {
self.error_count + self.warning_count + self.info_count
}
}