paths.rs

 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() {
17    println!("\n## Run Data\n");
18
19    let current_dir = std::env::current_dir().unwrap();
20    for file in std::fs::read_dir(&*RUN_DIR).unwrap() {
21        let file = file.unwrap();
22        if file.file_type().unwrap().is_dir() {
23            for file in std::fs::read_dir(file.path()).unwrap() {
24                let path = file.unwrap().path();
25                let path = path.strip_prefix(&current_dir).unwrap_or(&path);
26                println!(
27                    "- {}/\x1b[34m{}\x1b[0m",
28                    path.parent().unwrap().display(),
29                    path.file_name().unwrap().display(),
30                );
31            }
32        } else {
33            let path = file.path();
34            println!(
35                "- {} ",
36                path.strip_prefix(&current_dir).unwrap_or(&path).display()
37            );
38        }
39    }
40}