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) {
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 "- {}/\x1b[34m{}\x1b[0m",
29 path.parent().unwrap().display(),
30 path.file_name().unwrap().display(),
31 ));
32 }
33 } else {
34 let path = file.path();
35 let path = path.strip_prefix(¤t_dir).unwrap_or(&path);
36 files.push(format!(
37 "- {}/\x1b[34m{}\x1b[0m",
38 path.parent().unwrap().display(),
39 path.file_name().unwrap().display(),
40 ));
41 }
42 }
43 files.sort();
44
45 for file in files {
46 println!("{}", file);
47 }
48
49 println!(
50 "\n💡 Tip of the day: {} always points to the latest run\n",
51 LATEST_EXAMPLE_RUN_DIR.display()
52 );
53}