1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
use amisgitpm::ProjectIface;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, Default)]
pub enum UpdatePolicy {
Always,
Ask,
#[default]
Never,
}
impl std::fmt::Display for UpdatePolicy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Always => {
write!(f, "Always try to update the project")
}
Self::Ask => {
write!(f, "Ask wether ot update or not")
}
Self::Never => {
write!(f, "Never try to update the project")
}
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Default)]
pub struct Project {
pub name: String,
pub dir: String,
pub url: String,
pub ref_string: String,
pub update_policy: UpdatePolicy,
pub install_script: Vec<String>,
pub uninstall_script: Vec<String>,
}
impl ProjectIface for Project {
fn get_name(&self) -> &str {
&self.name
}
fn get_dir(&self) -> &str {
&self.dir
}
fn get_url(&self) -> &str {
&self.url
}
fn get_ref_string(&self) -> &str {
&self.ref_string
}
fn get_install(&self) -> &[String] {
&self.install_script
}
fn get_uninstall(&self) -> &[String] {
&self.uninstall_script
}
}