use std::{path::PathBuf, time::SystemTime};
use crate::tk::Model;
#[derive(Debug, Clone, clap::Args)]
pub struct FsScannerOpts {
#[arg(long, default_value_t = false)]
pub no_gitignore: bool,
#[arg(long, default_value_t = false)]
pub no_git_global: bool,
#[arg(long, default_value_t = false)]
pub no_git_exclude: bool,
#[arg(long)]
pub custom_ignore_path: Option<PathBuf>,
#[arg(short = 'i', long, value_delimiter = ',')]
pub ignore_patterns: Vec<String>,
#[arg(short = 'I', long, value_delimiter = ',')]
pub include_patterns: Vec<String>,
#[arg(short = 'L', long, default_value_t = false)]
pub follow_symlinks: bool,
#[arg(short = 'a', long, default_value_t = false)]
pub hidden: bool,
#[arg(short = 'd', long)]
pub max_depth: Option<usize>,
#[arg(skip)]
pub modified_after: Option<SystemTime>,
#[arg(skip)]
pub modified_before: Option<SystemTime>,
#[arg(skip)]
pub permissions_filter: Option<u32>,
#[arg(short = 'S', long)]
pub max_file_size_for_content: Option<u64>,
#[arg(long, default_value_t = false)]
pub skip_content: bool,
#[arg(long, default_value_t = 0.9)]
pub text_detection_ratio: f32,
#[arg(long, default_value_t = 8192)]
pub text_detection_buffer_size: usize,
#[arg(long)]
pub num_walker_threads: Option<usize>,
#[arg(long)]
pub num_processor_threads: Option<usize>,
#[arg(long, default_value_t = 1000)]
pub channel_capacity: usize,
#[arg(long)]
pub modified_after_timestamp: Option<u64>,
#[arg(long)]
pub modified_before_timestamp: Option<u64>,
#[arg(long, value_enum)]
pub model: Option<Model>, #[arg(long, value_enum)]
pub ignore_inline_tests: bool,
}
impl Default for FsScannerOpts {
fn default() -> Self {
Self {
no_gitignore: false,
no_git_global: false,
no_git_exclude: false,
custom_ignore_path: None,
ignore_patterns: Vec::new(),
include_patterns: Vec::new(),
follow_symlinks: false,
hidden: false, max_depth: None,
modified_after: None,
modified_before: None,
permissions_filter: None,
max_file_size_for_content: Some(2 * 1024 * 1024), skip_content: false,
text_detection_ratio: 0.9, text_detection_buffer_size: 8192, num_walker_threads: None, num_processor_threads: None, channel_capacity: 1000, modified_after_timestamp: None,
modified_before_timestamp: None,
model: None, ignore_inline_tests: true,
}
}
}
impl FsScannerOpts {
pub fn post_process(&mut self) {
if let Some(ts) = self.modified_after_timestamp {
self.modified_after = Some(
SystemTime::UNIX_EPOCH
.checked_add(std::time::Duration::from_secs(ts))
.unwrap_or(SystemTime::UNIX_EPOCH),
);
}
if let Some(ts) = self.modified_before_timestamp {
self.modified_before = Some(
SystemTime::UNIX_EPOCH
.checked_add(std::time::Duration::from_secs(ts))
.unwrap_or(SystemTime::now()),
);
}
}
}