1pub struct Config {
5 pub default_slides: usize,
7 pub default_title: String,
9 pub default_output_dir: String,
11 pub default_extension: String,
13}
14
15impl Config {
16 pub fn default() -> Self {
18 Config {
19 default_slides: 1,
20 default_title: "Presentation".to_string(),
21 default_output_dir: "output".to_string(),
22 default_extension: "pptx".to_string(),
23 }
24 }
25
26 pub fn new(
28 default_slides: usize,
29 default_title: &str,
30 default_output_dir: &str,
31 default_extension: &str,
32 ) -> Self {
33 Config {
34 default_slides,
35 default_title: default_title.to_string(),
36 default_output_dir: default_output_dir.to_string(),
37 default_extension: default_extension.to_string(),
38 }
39 }
40
41 pub fn output_path(&self, filename: &str) -> String {
43 format!("{}/{}.{}", self.default_output_dir, filename, self.default_extension)
44 }
45}
46
47pub struct CliConfig {
49 pub app_name: String,
50 pub version: String,
51 pub author: String,
52}
53
54impl CliConfig {
55 pub fn default() -> Self {
57 CliConfig {
58 app_name: "pptcli".to_string(),
59 version: "1.0.2".to_string(),
60 author: "PPTX Generator".to_string(),
61 }
62 }
63}
64
65pub struct GeneratorConfig {
67 pub default_theme: String,
68 pub default_layout: String,
69 pub default_master: String,
70}
71
72impl GeneratorConfig {
73 pub fn default() -> Self {
75 GeneratorConfig {
76 default_theme: "theme1".to_string(),
77 default_layout: "slideLayout1".to_string(),
78 default_master: "slideMaster1".to_string(),
79 }
80 }
81}
82
83#[cfg(test)]
84mod tests {
85 use super::*;
86
87 #[test]
88 fn test_default_config() {
89 let config = Config::default();
90 assert_eq!(config.default_slides, 1);
91 assert_eq!(config.default_title, "Presentation");
92 }
93
94 #[test]
95 fn test_custom_config() {
96 let config = Config::new(5, "Custom", "out", "pptx");
97 assert_eq!(config.default_slides, 5);
98 assert_eq!(config.default_title, "Custom");
99 }
100
101 #[test]
102 fn test_output_path() {
103 let config = Config::default();
104 let path = config.output_path("test");
105 assert_eq!(path, "output/test.pptx");
106 }
107}