use std::path::PathBuf;
use crate::model::ItemType;
#[derive(Debug, Clone)]
pub struct InitOptions {
pub file: PathBuf,
pub item_type: ItemType,
pub id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub refines: Vec<String>,
pub derives_from: Vec<String>,
pub satisfies: Vec<String>,
pub specification: Option<String>,
pub platform: Option<String>,
pub force: bool,
}
impl InitOptions {
pub fn new(file: PathBuf, item_type: ItemType) -> Self {
Self {
file,
item_type,
id: None,
name: None,
description: None,
refines: Vec::new(),
derives_from: Vec::new(),
satisfies: Vec::new(),
specification: None,
platform: None,
force: false,
}
}
pub fn with_id(mut self, id: impl Into<String>) -> Self {
self.id = Some(id.into());
self
}
pub fn with_name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn with_description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
pub fn with_refines(mut self, refines: Vec<String>) -> Self {
self.refines = refines;
self
}
pub fn with_derives_from(mut self, derives_from: Vec<String>) -> Self {
self.derives_from = derives_from;
self
}
pub fn with_satisfies(mut self, satisfies: Vec<String>) -> Self {
self.satisfies = satisfies;
self
}
pub fn with_specification(mut self, specification: impl Into<String>) -> Self {
self.specification = Some(specification.into());
self
}
pub fn with_platform(mut self, platform: impl Into<String>) -> Self {
self.platform = Some(platform.into());
self
}
pub fn with_force(mut self, force: bool) -> Self {
self.force = force;
self
}
}