use assemble_core::file_collection::FileSet;
use assemble_core::project::VisitProject;
use assemble_core::utilities::{Spec, Work};
use assemble_core::Project;
use std::path::{Path, PathBuf};
pub struct DupeSpec {
from: Option<FileSet>,
into: Option<PathBuf>,
include: Box<dyn Spec<Path>>,
exclude: Box<dyn Spec<Path>>,
parent: Option<Box<DupeSpec>>,
}
impl DupeSpec {
fn get_from(&self) -> Option<&FileSet> {
self.from
.as_ref()
.or_else(|| self.parent.as_ref().and_then(|p| p.get_from()))
}
fn get_into(&self) -> Option<&Path> {
self.into
.as_deref()
.or_else(|| self.parent.as_ref().and_then(|p| p.get_into()))
}
fn is_included(&self, path: &Path) -> bool {
if let Some(parent) = &self.parent {
if !parent.is_included(path) {
return false;
}
}
self.include.accept(path) && !self.exclude.accept(path)
}
}
impl VisitProject<Work> for DupeSpec {
fn visit(&mut self, _project: &Project) -> Work {
todo!()
}
}