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