diff --git a/Cargo.lock b/Cargo.lock index c862e14..20732c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,7 +258,7 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -401,6 +401,27 @@ dependencies = [ "crypto-common", ] +[[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" @@ -461,7 +482,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -680,6 +701,7 @@ dependencies = [ "comfy-table", "console", "demand", + "dirs", "httpmock", "reqwest", "serde", @@ -1028,6 +1050,16 @@ version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +[[package]] +name = "libredox" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" +dependencies = [ + "bitflags", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.11.0" @@ -1108,6 +1140,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "parking" version = "2.2.1" @@ -1300,6 +1338,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.16", + "libredox", + "thiserror 2.0.17", +] + [[package]] name = "regex" version = "1.12.2" @@ -1399,7 +1448,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1456,7 +1505,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -2152,7 +2201,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a603d57..2688195 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,5 @@ demand = "1.8.0" console = "0.16.2" colored = "3.0.0" httpmock = "0.8.2" -serde_json = "1.0.145" \ No newline at end of file +serde_json = "1.0.145" +dirs = "6.0.0" diff --git a/src/clone.rs b/src/clone.rs index ffd4b9e..7140242 100644 --- a/src/clone.rs +++ b/src/clone.rs @@ -1,8 +1,8 @@ use console::Term; use demand::{DemandOption, MultiSelect}; +use dirs; use std::{ fs, - path::Path, process::{Command, Stdio}, }; @@ -87,14 +87,19 @@ impl Clone { if let Err(e) = Self::clone_repo(url) { CliOutput::error(term, &format!("cloning {url}: {e}")); } else { - CliOutput::success(term, &format!("cloned {url}")); + CliOutput::success( + term, + &format!("cloned {url}. You can find it in the 'heroesofcode' folder on your Desktop."), + ); } } - /// Clones a repository into the local organization directory + /// Clones a repository into the heroesofcode folder on the user's Desktop fn clone_repo(url: &str) -> Result<(), String> { - let base = Path::new("heroesofcode"); - fs::create_dir_all(base).map_err(|e| e.to_string())?; + let base = dirs::desktop_dir() + .ok_or("Could not find Desktop!")? + .join("heroesofcode"); + fs::create_dir_all(&base).map_err(|e| e.to_string())?; let name = url.rsplit('/').next().ok_or("invalid url")?; let full_url = format!("{url}.git"); @@ -105,7 +110,7 @@ impl Clone { Command::new("git") .args(["clone", &full_url]) - .current_dir(base) + .current_dir(&base) .stdout(Stdio::null()) .stderr(Stdio::null()) .status()