1use std::{env, path::PathBuf, sync::LazyLock};
2
3pub static TARGET_ZETA_DIR: LazyLock<PathBuf> =
4 LazyLock::new(|| env::current_dir().unwrap().join("target/zeta"));
5pub static CACHE_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_ZETA_DIR.join("cache"));
6pub static REPOS_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_ZETA_DIR.join("repos"));
7pub static WORKTREES_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_ZETA_DIR.join("worktrees"));
8pub static RUN_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
9 TARGET_ZETA_DIR
10 .join("runs")
11 .join(chrono::Local::now().format("%d-%m-%y-%H_%M_%S").to_string())
12});
13pub static LATEST_EXAMPLE_RUN_DIR: LazyLock<PathBuf> =
14 LazyLock::new(|| TARGET_ZETA_DIR.join("latest"));
15
16pub fn print_run_data_dir(deep: bool, use_color: bool) {
17 println!("\n## Run Data\n");
18 let mut files = Vec::new();
19
20 let current_dir = std::env::current_dir().unwrap();
21 for file in std::fs::read_dir(&*RUN_DIR).unwrap() {
22 let file = file.unwrap();
23 if file.file_type().unwrap().is_dir() && deep {
24 for file in std::fs::read_dir(file.path()).unwrap() {
25 let path = file.unwrap().path();
26 let path = path.strip_prefix(¤t_dir).unwrap_or(&path);
27 files.push(format!(
28 "- {}/{}{}{}",
29 path.parent().unwrap().display(),
30 if use_color { "\x1b[34m" } else { "" },
31 path.file_name().unwrap().display(),
32 if use_color { "\x1b[0m" } else { "" },
33 ));
34 }
35 } else {
36 let path = file.path();
37 let path = path.strip_prefix(¤t_dir).unwrap_or(&path);
38 files.push(format!(
39 "- {}/{}{}{}",
40 path.parent().unwrap().display(),
41 if use_color { "\x1b[34m" } else { "" },
42 path.file_name().unwrap().display(),
43 if use_color { "\x1b[0m" } else { "" }
44 ));
45 }
46 }
47 files.sort();
48
49 for file in files {
50 println!("{}", file);
51 }
52
53 println!(
54 "\n💡 Tip of the day: {} always points to the latest run\n",
55 LATEST_EXAMPLE_RUN_DIR.display()
56 );
57}