tempo_cli/models/
template.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct ProjectTemplate {
7 pub id: Option<i64>,
8 pub name: String,
9 pub description: Option<String>,
10 pub default_tags: Vec<String>,
11 pub default_goals: Vec<TemplateGoal>,
12 pub workspace_path: Option<PathBuf>,
13 pub created_at: DateTime<Utc>,
14}
15
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
17pub struct TemplateGoal {
18 pub name: String,
19 pub target_hours: f64,
20 pub description: Option<String>,
21}
22
23impl ProjectTemplate {
24 pub fn new(name: String) -> Self {
25 Self {
26 id: None,
27 name,
28 description: None,
29 default_tags: Vec::new(),
30 default_goals: Vec::new(),
31 workspace_path: None,
32 created_at: Utc::now(),
33 }
34 }
35
36 pub fn with_description(mut self, description: String) -> Self {
37 self.description = Some(description);
38 self
39 }
40
41 pub fn with_tags(mut self, tags: Vec<String>) -> Self {
42 self.default_tags = tags;
43 self
44 }
45
46 pub fn with_goals(mut self, goals: Vec<TemplateGoal>) -> Self {
47 self.default_goals = goals;
48 self
49 }
50
51 pub fn with_workspace_path(mut self, path: PathBuf) -> Self {
52 self.workspace_path = Some(path);
53 self
54 }
55}
56