diff --git a/.gitignore b/.gitignore index 096f2fd15..c5dd4628e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target .env -attractor-run-* diff --git a/Cargo.lock b/Cargo.lock index 8f263e7d3..9479b1a5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,6 +167,7 @@ dependencies = [ "chrono", "clap", "dialoguer", + "dirs", "dotenvy", "futures", "http-body-util", @@ -544,6 +545,27 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -1525,6 +1547,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "outref" version = "0.5.2" @@ -1798,6 +1826,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 2.0.18", +] + [[package]] name = "ref-cast" version = "1.0.25" diff --git a/crates/attractor/Cargo.toml b/crates/attractor/Cargo.toml index 7dc900ee1..6600b9ebb 100644 --- a/crates/attractor/Cargo.toml +++ b/crates/attractor/Cargo.toml @@ -37,6 +37,7 @@ async-trait.workspace = true futures.workspace = true chrono = { workspace = true, features = ["serde"] } nom = "7" +dirs = "6" dialoguer.workspace = true axum = { version = "0.8", optional = true } tower = { version = "0.5", optional = true } diff --git a/crates/attractor/src/cli/run.rs b/crates/attractor/src/cli/run.rs index 254c1aca4..31c7e3c85 100644 --- a/crates/attractor/src/cli/run.rs +++ b/crates/attractor/src/cli/run.rs @@ -1,4 +1,3 @@ -use std::path::PathBuf; use std::sync::{Arc, Mutex}; use std::time::Instant; @@ -60,7 +59,11 @@ pub async fn run_command(args: RunArgs, styles: &'static Styles) -> anyhow::Resu // 2. Create logs directory let logs_dir = args.logs_dir.unwrap_or_else(|| { - PathBuf::from(format!( + let base = dirs::home_dir() + .expect("could not determine home directory") + .join(".attractor") + .join("logs"); + base.join(format!( "attractor-run-{}", Local::now().format("%Y%m%d-%H%M%S") ))