From e87dc69a2350cf8ccbd2d9772aa1220900de6813 Mon Sep 17 00:00:00 2001 From: Souvik Chakraborty Date: Wed, 8 Oct 2025 04:24:28 +0530 Subject: [PATCH 1/2] added remote path functionality --- Cargo.lock | 372 +++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 4 + src/config.rs | 54 ++++++++ src/main.rs | 156 +++++++++++++++++++-- 4 files changed, 566 insertions(+), 20 deletions(-) create mode 100644 src/config.rs diff --git a/Cargo.lock b/Cargo.lock index 194d5ee..0808a18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -60,6 +70,18 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "bitflags" +version = "2.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" + [[package]] name = "camino" version = "1.1.9" @@ -89,9 +111,15 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror", + "thiserror 2.0.4", ] +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + [[package]] name = "clap" version = "4.5.21" @@ -123,7 +151,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -142,14 +170,83 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" name = "crunch-app" version = "0.0.12" dependencies = [ + "anyhow", "cargo_metadata", "clap", + "directories", + "dirs", "env_logger", "log", + "metre", "serde", "xdg", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[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", +] + [[package]] name = "env_filter" version = "0.1.2" @@ -173,6 +270,35 @@ dependencies = [ "log", ] +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "heck" version = "0.5.0" @@ -185,6 +311,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -197,6 +339,28 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.176" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" + +[[package]] +name = "libredox" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +dependencies = [ + "bitflags", + "libc", +] + [[package]] name = "log" version = "0.4.22" @@ -209,6 +373,53 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "metre" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3af7dde5c8126e43af8aacb6421807e9022e0100a42cffc7ea76d09c3a17bb6f" +dependencies = [ + "metre-macros", + "owo-colors", + "serde", + "serde_json", + "thiserror 1.0.69", + "toml", +] + +[[package]] +name = "metre-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77812977a82dd9133f6137dd79954d3b5d19a4bc7974d8d30491b61681e74ef" +dependencies = [ + "Inflector", + "darling", + "proc-macro2", + "quote", + "regex", + "regex_static", + "syn 2.0.87", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "owo-colors" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" + [[package]] name = "proc-macro2" version = "1.0.89" @@ -227,6 +438,17 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom", + "libredox", + "thiserror 2.0.4", +] + [[package]] name = "regex" version = "1.11.1" @@ -236,7 +458,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] @@ -247,15 +469,55 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "regex_static" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6126d61c5e4b41929098f73b42fc1d257116cc95d19739248c51591f77cc0021" +dependencies = [ + "once_cell", + "regex", + "regex_static_macro", +] + +[[package]] +name = "regex_static_impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3755019886a70e772e6360b0b58501d75cf7dc17a53e08aa97e59ecb2c2bc5" +dependencies = [ + "proc-macro2", + "quote", + "regex-syntax 0.6.29", + "syn 1.0.109", +] + +[[package]] +name = "regex_static_macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b15495fd034158635bc8b762a132dfc83864d6992aeda1ffabf01b03b611a1" +dependencies = [ + "proc-macro2", + "regex_static_impl", + "syn 1.0.109", +] + [[package]] name = "ryu" version = "1.0.18" @@ -288,7 +550,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -303,12 +565,32 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.87" @@ -320,13 +602,33 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.4", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -337,9 +639,50 @@ checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "unicode-ident" version = "1.0.13" @@ -352,6 +695,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "windows-sys" version = "0.59.0" @@ -425,6 +774,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + [[package]] name = "xdg" version = "2.5.2" diff --git a/Cargo.toml b/Cargo.toml index 46d305b..5a45b8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,10 @@ xdg = "2.1.0" serde = { version = "1.0", features = ["derive"] } clap = { version = "4.5.21", default-features = true, features = ["derive"] } env_logger = "0.11.5" +metre = "0.2.6" +directories = "6.0.0" +dirs = "6.0.0" +anyhow = "1.0.100" [[bin]] name = "crunch" diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..d229ae1 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,54 @@ +use metre::{Config, ConfigLoader, Format}; + + +#[derive(Config, Debug)] +pub struct AppConfig { + #[config(default= "mirror".to_string())] + pub remote_path: String, + + #[config(default = 30)] + pub timeout_secs: u64, + + #[config(default = false)] + pub verbose: bool, + + #[config(default = "target,.git".to_string())] + pub exclude: String, + + #[config(default = "RUST_BACKTRACE=1".to_string())] + pub build_env: String, +} + + +impl AppConfig { + pub fn load_config() -> Result { + let mut loader = ConfigLoader::::new(); + loader.defaults()?; + + if let Some(home) = dirs::home_dir() { + let cfg_path = home.join(".config").join("crunch.toml"); + if cfg_path.exists() { + if let Some(path_str) = cfg_path.to_str() { + loader.file(path_str, Format::Toml)?; + } else { + eprint!("Path is not valid UTF-8: {:?}", cfg_path); + } + } else { + eprint!("Config file not found: {}", cfg_path.display()); + } + } + + // Load from project-specific config if it exists + if let Ok(manifest) = std::env::current_dir() { + let project_cfg = manifest.join("crunch.toml"); + if project_cfg.exists() { + if let Some(path_str) = project_cfg.to_str() { + loader.file(path_str, Format::Toml)?; + } + } + } + loader.env()?; + + loader.finish() + } +} diff --git a/src/main.rs b/src/main.rs index 0e33c70..2353478 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,9 @@ //! //! crunch seamlessly integrates cutting-edge hardware into your local development environment. + +mod config; +use config::AppConfig; use cargo_metadata::camino::Utf8PathBuf; use clap::{command, Parser, ValueEnum}; use log::{debug, error, info}; @@ -37,15 +40,31 @@ enum RemotePathBehavior { version, about, trailing_var_arg = true, - after_long_help = "EXAMPLES:\n crunch -e RUST_LOG=debug check --all-features --all-targets\n crunch test -- --nocapture" + after_long_help = "EXAMPLES:\n crunch -v build --release\n crunch -e RUST_LOG=debug check --all-features --all-targets\n crunch test -- --nocapture" )] struct Args { + /// Verbose flag (must come before cargo command) + #[arg(short, long, global = true)] + verbose: bool, + + /// Override timeout seconds for this run + #[arg(long, global = true)] + timeout_secs: Option, + + /// Where crunch should place the project on the remote server. + #[arg(long = "remote-path", required = false, default_value = "mirror", global = true)] + remote_path: RemotePathBehavior, + + /// Optional: print final effective config and exit (debug) + #[arg(long, global = true)] + print_config: bool, /// Set remote environment variables. RUST_BACKTRACE, CC, LIB, etc. #[arg( short = 'e', long, required = false, - default_value = "RUST_BACKTRACE=1" + default_value = "RUST_BACKTRACE=1", + global = true )] build_env: String, @@ -59,34 +78,30 @@ struct Args { long = "exclude", required = false, value_delimiter = ',', - default_value = "target,.git" + default_value = "target,.git", + global = true )] exclude: Vec, /// A command to execute on the machine after the cargo command has finished executing. /// /// Example: `--post-cargo "cd target/release && profile my-binary"` - #[arg(long = "post-cargo", required = false)] + #[arg(long = "post-cargo", required = false, global = true)] post_cargo: Option, /// Path or directory to sync back from the remote server after all other work has been done. /// Each entry should be in the format `source:destination`. Specify multiple entries using delimiter ','. /// /// Example: `--copy-back "./target/release/cuter-cat.png:.,*.bin:~/my-bins"` - #[arg(long = "copy-back", required = false, value_delimiter = ',')] + #[arg(long = "copy-back", required = false, value_delimiter = ',', global = true)] copy_back: Vec, - /// Where crunch should place the project on the remote server. - #[arg(long = "remote-path", required = false, default_value = "mirror")] - remote_path: RemotePathBehavior, - /// The cargo command to execute /// /// Example: `build --release` #[arg(required = true, num_args = 1..)] command: Vec, } - fn uid_from_path(path: &Utf8PathBuf) -> u64 { let mut hasher = DefaultHasher::new(); path.as_str().hash(&mut hasher); @@ -94,12 +109,71 @@ fn uid_from_path(path: &Utf8PathBuf) -> u64 { } fn main() { + + let cfg = AppConfig::load_config() + .unwrap_or_else(|e| { + eprintln!("Warning: Failed to load configuration: {}", e); + eprintln!("Using default values..."); + // Return defaults if config loading fails + AppConfig { + remote_path: "mirror".to_string(), + timeout_secs: 30, + verbose: false, + exclude: "target,.git".to_string(), + build_env: "RUST_BACKTRACE=1".to_string(), + } + }); + + // Parse command line args - these will override config + let mut args = Args::parse(); + + // Apply config values if CLI args are at their defaults + if args.remote_path.matches_default() { + args.remote_path = parse_remote_path_behavior(&cfg.remote_path); + } + + if args.timeout_secs.is_none() { + args.timeout_secs = Some(cfg.timeout_secs); + } + + if !args.verbose { + args.verbose = cfg.verbose; + } + + if args.exclude.len() == 2 && args.exclude[0] == "target" && args.exclude[1] == ".git" { + args.exclude = cfg.exclude.split(',').map(|s| s.trim().to_string()).collect(); + } + + if args.build_env == "RUST_BACKTRACE=1" { + args.build_env = cfg.build_env.clone(); + } + + // Initialize logger after merging verbose flag + let log_level = if args.verbose { + log::LevelFilter::Debug + } else { + log::LevelFilter::Info + }; + env_logger::builder() - .filter_level(log::LevelFilter::Info) + .filter_level(log_level) .init(); - let args = Args::parse(); - debug!("{:?}", &args); + debug!("Loaded config: {:?}", &cfg); + debug!("Final args after config merge: {:?}", &args); + + // Handle --print-config flag + if args.print_config { + println!("Final effective configuration:"); + println!(" remote_path: {:?}", args.remote_path); + println!(" timeout_secs: {:?}", args.timeout_secs); + println!(" verbose: {}", args.verbose); + println!(" exclude: {:?}", args.exclude); + println!(" build_env: {}", args.build_env); + println!(" command: {:?}", args.command); + return; + } + let copy_back_pairs: Vec<(String, String)> = args .copy_back @@ -186,6 +260,41 @@ fn main() { rsync_to.arg("--exclude").arg(exclude); }); + + debug!("Project directory: {}", project_dir); + debug!("Build server: {}", build_server); + debug!("Build path: {}", build_path); + debug!("Remote SSH port: {}", remote.ssh_port); + + info!("Transferring sources to remote: {}", build_path); + + // Test SSH connectivity first + debug!("Testing SSH connection to {}...", build_server); + let ssh_test = Command::new("ssh") + .args(["-p", &remote.ssh_port.to_string()]) + .arg("-o") + .arg("ConnectTimeout=5") + .arg(&build_server) + .arg("echo 'SSH connection successful'") + .output(); + + match ssh_test { + Ok(output) if output.status.success() => { + debug!("SSH connection test passed"); + } + Ok(output) => { + error!("SSH connection failed with exit code: {}", output.status); + error!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + eprintln!("\nHint: Make sure you can connect with: ssh -p {} {}", remote.ssh_port, build_server); + exit(-3); + } + Err(e) => { + error!("Failed to execute SSH command: {}", e); + eprintln!("\nHint: Make sure 'ssh' is installed and in your PATH"); + exit(-3); + } + } + let rsync_path_arg = format!("mkdir -p {build_path} && rsync"); rsync_to @@ -372,3 +481,24 @@ fn extract_manifest_path_works() { let args = vec!["build".to_string(), "--release".to_string()]; assert_eq!(extract_manifest_path(&args), None); } + + +// Helper function to parse remote_path string into enum +fn parse_remote_path_behavior(s: &str) -> RemotePathBehavior { + match s.to_lowercase().as_str() { + "mirror" => RemotePathBehavior::Mirror, + "tmp" => RemotePathBehavior::Tmp, + "unique" => RemotePathBehavior::Unique, + _ => { + eprintln!("Warning: Unknown remote_path value '{}', using 'mirror'", s); + RemotePathBehavior::Mirror + } + } +} + +// Add this helper trait for RemotePathBehavior +impl RemotePathBehavior { + fn matches_default(&self) -> bool { + matches!(self, RemotePathBehavior::Mirror) + } +} From c07009ead88befa1543401d10e642524c632238b Mon Sep 17 00:00:00 2001 From: Souvik Chakraborty Date: Wed, 8 Oct 2025 04:25:27 +0530 Subject: [PATCH 2/2] update --- Cargo.lock | 17 ----------------- Cargo.toml | 2 -- 2 files changed, 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0808a18..7ba5763 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,12 +70,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "anyhow" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" - [[package]] name = "bitflags" version = "2.9.4" @@ -170,10 +164,8 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" name = "crunch-app" version = "0.0.12" dependencies = [ - "anyhow", "cargo_metadata", "clap", - "directories", "dirs", "env_logger", "log", @@ -217,15 +209,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "directories" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs" version = "6.0.0" diff --git a/Cargo.toml b/Cargo.toml index 5a45b8e..fab2250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,7 @@ serde = { version = "1.0", features = ["derive"] } clap = { version = "4.5.21", default-features = true, features = ["derive"] } env_logger = "0.11.5" metre = "0.2.6" -directories = "6.0.0" dirs = "6.0.0" -anyhow = "1.0.100" [[bin]] name = "crunch"