use std::error::Error;
#[derive(Debug, Clone)]
pub struct VueProject {
pub use_monorepo: bool,
pub working_name: Option<String>,
pub is_sub_project: bool,
pub use_test: bool,
pub use_sub_project: bool,
pub sub_project_name: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CopyType {
File,
Dir,
}
pub struct CopyProject {
pub source_path: String,
pub target_path: String,
pub copy_type: CopyType,
pub need_process_content: bool,
pub content_processor: Option<Box<dyn Fn(&str) -> Result<String, Box<dyn Error>>>>,
}
impl CopyProject {
pub fn with_dir (
source_path: String,
target_path: String,
) -> CopyProject {
CopyProject {
source_path,
target_path,
copy_type: CopyType::Dir,
need_process_content: false,
content_processor: None,
}
}
pub fn with_file (
source_path: String,
target_path: String,
) -> CopyProject {
CopyProject {
source_path,
target_path,
copy_type: CopyType::File,
need_process_content: false,
content_processor: None,
}
}
pub fn with_content_processor(
mut self,
processor: impl Fn(&str) -> Result<String, Box<dyn Error>> + 'static,
) -> Self {
self.content_processor = Some(Box::new(processor));
self.need_process_content = true;
self
}
}