mod colors;
#[cfg(feature = "cli")]
mod markdown;
mod tree;
use crate::{config::IgnorePatterns, format::OutputFormat};
#[cfg(feature = "cli")]
use crate::{error::Result, walker::WalkerEntry};
use std::path::PathBuf;
pub use colors::Colors;
#[cfg(feature = "cli")]
pub use markdown::MarkdownPrinter;
pub use tree::{TreePrinter, format_tree};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SkipPatterns(bool);
impl SkipPatterns {
pub const ENABLED: Self = Self(true);
pub const DISABLED: Self = Self(false);
#[must_use]
pub const fn should_skip(self) -> bool {
self.0
}
}
#[derive(Debug, Clone)]
pub struct PrinterOptions {
pub format: OutputFormat,
pub root: PathBuf,
pub skip_patterns: SkipPatterns,
pub patterns: IgnorePatterns,
}
#[cfg(feature = "cli")]
pub fn print_file(entry: &WalkerEntry, options: &PrinterOptions) -> Result<()> {
match options.format {
OutputFormat::Markdown => MarkdownPrinter::print(
entry,
&options.root,
&options.patterns,
options.skip_patterns,
),
OutputFormat::Tree => TreePrinter::print(entry, &options.root),
}
}