diff --git a/Cargo.lock b/Cargo.lock index 45baa6d..074992c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ name = "ah" version = "0.1.0" dependencies = [ "clap", + "colored", ] [[package]] @@ -45,7 +46,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -55,7 +56,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -104,6 +105,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "heck" version = "0.5.0" @@ -116,6 +127,12 @@ version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "proc-macro2" version = "1.0.86" @@ -163,13 +180,37 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -178,28 +219,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -212,24 +271,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index a52eb25..f8b90ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,4 @@ edition = "2021" [dependencies] clap = { version = "4.5.10", features = ["derive"] } +colored = "2.1.0" diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..939f33f --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,27 @@ +use clap::{Parser, Subcommand, Args}; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +pub struct Cli { + #[command(subcommand)] + pub command: Option, +} + +#[derive(Subcommand, Debug)] +pub enum SubCommands { + #[command(alias = "i")] + Install(PackageArg), + #[command(alias = "u")] + Upgrade {}, + #[command(alias = "s")] + Sync {}, + #[command(alias = "r")] + Remove(PackageArg), + #[command(alias = "f")] + Find(PackageArg), +} + +#[derive(Args, Debug)] +pub struct PackageArg { + pub package: String, +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3ea2945..a08591f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,40 +1,17 @@ -use clap::{Command, Parser, Subcommand, Args}; +use clap::Parser; -#[derive(Parser, Debug)] -#[command(version, about, long_about = None)] -struct Cli { - #[command(subcommand)] - pub command: Option, -} - -#[derive(Subcommand, Debug)] -enum SubCommands { - #[command(alias = "i")] - Install(PackageArg), - #[command(alias = "u")] - Upgrade {}, - #[command(alias = "s")] - Sync {}, - #[command(alias = "r")] - Remove(PackageArg), - #[command(alias = "f")] - Find(PackageArg), -} - -#[derive(Args, Debug)] -struct PackageArg { - package: String, -} +mod cli; +mod packages; fn main() { - let cli = Cli::parse(); + let cli = cli::Cli::parse(); match cli.command { - Some(SubCommands::Install(arg)) => println!("Installing package: {}", arg.package), - Some(SubCommands::Upgrade {}) => todo!(), - Some(SubCommands::Sync {}) => todo!(), - Some(SubCommands::Remove(arg)) => println!("Removing package: {}", arg.package), - Some(SubCommands::Find(arg)) => println!("Looking for package: {}", arg.package), - None => println!("No subcommand was used"), + Some(cli::SubCommands::Install(arg)) => packages::install(&arg.package), + Some(cli::SubCommands::Upgrade {}) => packages::upgrade(), + Some(cli::SubCommands::Sync {}) => packages::sync(), + Some(cli::SubCommands::Remove(arg)) => packages::remove(&arg.package), + Some(cli::SubCommands::Find(arg)) => packages::find(&arg.package), + None => packages::sync(), } } diff --git a/src/packages.rs b/src/packages.rs new file mode 100644 index 0000000..5834ef2 --- /dev/null +++ b/src/packages.rs @@ -0,0 +1,38 @@ +use colored::Colorize; +use std::process::Command; + +const PACKAGE_MANAGER: &str = "paru"; + +pub fn sync() { + println!("{} {}", "::".bold().green(), "Syncing packages...".bold()); + todo!(); +} + +pub fn upgrade() { + println!("{} {}", "::".bold().green(), "Upgrading packages...".bold()); + todo!(); +} + +pub fn install(package: &str) { + println!("{} {}", "::".bold().green(), "Installing packages...".bold()); + todo!(); +} + +pub fn remove(package: &str) { + println!("{} {}", "::".bold().green(), "Removing packages...".bold()); + todo!(); +} + +pub fn find(package: &str) { + println!("{} {}", "::".bold().green(), "Looking for package...".bold()); + + let output = Command::new(PACKAGE_MANAGER) + .arg("--color") + .arg("always") + .arg("-Ss") + .arg(package) + .output() + .expect("Failed to execute command"); + + print!("{}", String::from_utf8_lossy(&output.stdout)); +} \ No newline at end of file