dodot_lib/commands/
mod.rs1pub mod addignore;
9pub mod adopt;
10pub mod down;
11pub mod fill;
12pub mod init;
13pub mod list;
14pub mod status;
15pub mod up;
16
17#[cfg(test)]
18mod tests;
19
20use serde::Serialize;
21
22pub fn handler_symbol(handler: &str) -> &'static str {
26 match handler {
27 "symlink" => "➞",
28 "shell" => "⚙",
29 "path" => "+",
30 "homebrew" => "⚙",
31 "install" => "×",
32 _ => "?",
33 }
34}
35
36pub fn status_style(deployed: bool) -> &'static str {
38 if deployed {
39 "deployed"
40 } else {
41 "pending"
42 }
43}
44
45pub fn handler_description(handler: &str, rel_path: &str, user_target: Option<&str>) -> String {
47 match handler {
48 "symlink" => {
49 if let Some(target) = user_target {
50 target.to_string()
51 } else {
52 let display_path = if !rel_path.contains('/') && rel_path.starts_with("dot.") {
54 format!(".{}", &rel_path[4..])
55 } else {
56 format!(".{rel_path}")
57 };
58 format!("~/{display_path}")
59 }
60 }
61 "shell" => "shell profile".into(),
62 "path" => format!("$PATH/{rel_path}"),
63 "install" => "run script".into(),
64 "homebrew" => "brew install".into(),
65 _ => String::new(),
66 }
67}
68
69#[derive(Debug, Clone, Serialize)]
71pub struct DisplayFile {
72 pub name: String,
73 pub symbol: String,
74 pub description: String,
75 pub status: String,
76 pub status_label: String,
77 pub handler: String,
78}
79
80#[derive(Debug, Clone, Serialize)]
82pub struct DisplayPack {
83 pub name: String,
84 pub files: Vec<DisplayFile>,
85}
86
87#[derive(Debug, Clone, Serialize)]
90pub struct PackStatusResult {
91 #[serde(skip_serializing_if = "Option::is_none")]
92 pub message: Option<String>,
93 pub dry_run: bool,
94 pub packs: Vec<DisplayPack>,
95 #[serde(skip_serializing_if = "Vec::is_empty")]
96 pub warnings: Vec<String>,
97}