sara_core/init/
options.rs1use std::path::PathBuf;
4
5use crate::model::ItemType;
6
7#[derive(Debug, Clone)]
9pub struct InitOptions {
10 pub file: PathBuf,
12 pub item_type: ItemType,
14 pub id: Option<String>,
16 pub name: Option<String>,
18 pub description: Option<String>,
20 pub refines: Vec<String>,
22 pub derives_from: Vec<String>,
24 pub satisfies: Vec<String>,
26 pub specification: Option<String>,
28 pub platform: Option<String>,
30 pub force: bool,
32}
33
34impl InitOptions {
35 pub fn new(file: PathBuf, item_type: ItemType) -> Self {
37 Self {
38 file,
39 item_type,
40 id: None,
41 name: None,
42 description: None,
43 refines: Vec::new(),
44 derives_from: Vec::new(),
45 satisfies: Vec::new(),
46 specification: None,
47 platform: None,
48 force: false,
49 }
50 }
51
52 pub fn with_id(mut self, id: impl Into<String>) -> Self {
54 self.id = Some(id.into());
55 self
56 }
57
58 pub fn with_name(mut self, name: impl Into<String>) -> Self {
60 self.name = Some(name.into());
61 self
62 }
63
64 pub fn with_description(mut self, description: impl Into<String>) -> Self {
66 self.description = Some(description.into());
67 self
68 }
69
70 pub fn with_refines(mut self, refines: Vec<String>) -> Self {
72 self.refines = refines;
73 self
74 }
75
76 pub fn with_derives_from(mut self, derives_from: Vec<String>) -> Self {
78 self.derives_from = derives_from;
79 self
80 }
81
82 pub fn with_satisfies(mut self, satisfies: Vec<String>) -> Self {
84 self.satisfies = satisfies;
85 self
86 }
87
88 pub fn with_specification(mut self, specification: impl Into<String>) -> Self {
90 self.specification = Some(specification.into());
91 self
92 }
93
94 pub fn with_platform(mut self, platform: impl Into<String>) -> Self {
96 self.platform = Some(platform.into());
97 self
98 }
99
100 pub fn with_force(mut self, force: bool) -> Self {
102 self.force = force;
103 self
104 }
105}