diff --git a/src/cli.rs b/src/cli.rs index be23271..246ddde 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -27,34 +27,69 @@ pub enum Operations { Upgrade, Sync, AddRepo(AddRepo), + Downgrade(Downgrade), + Resume(Resume), } #[derive(Parser, Debug)] pub struct Install { - #[arg(index = 1)] + #[arg(short = 'p', long = "package", help = "Specify package(s) to install")] pub pkgs: Vec, + + #[arg(short = 'f', long = "force", help = "Force installation")] + pub force: bool, } #[derive(Parser, Debug)] pub struct Remove { - #[arg(index = 1)] + #[arg(short = 'p', long = "package", help = "Specify package(s) to remove")] pub pkgs: Vec, + + #[arg(short = 'y', long = "yes", help = "Automatically answer yes to prompts")] + pub yes: bool, } #[derive(Parser, Debug)] pub struct Search { - #[arg(index = 1)] + #[arg(short = 't', long = "term", help = "Specify search term(s)")] pub terms: Vec, + + #[arg(short = 'a', long = "all", help = "Search all available packages")] + pub all: bool, } #[derive(Parser, Debug)] pub struct Query { - #[arg(index = 1)] + #[arg(short = 't', long = "term", help = "Specify query term(s)")] pub terms: Vec, + + #[arg(short = 'd', long = "details", help = "Show detailed information")] + pub details: bool, } #[derive(Parser, Debug)] pub struct AddRepo { - #[arg(index = 1)] + #[arg(short = 'r', long = "repo", help = "Specify repository URL")] pub repo: String, + + #[arg(short = 'u', long = "update", help = "Update the repository list")] + pub update: bool, +} + +#[derive(Parser, Debug)] +pub struct Downgrade { + #[arg(short = 'p', long = "package", help = "Specify package(s) to downgrade")] + pub pkgs: Vec, + + #[arg(short = 'v', long = "version", help = "Specify version to downgrade to")] + pub version: Option, +} + +#[derive(Parser, Debug)] +pub struct Resume { + #[arg(short = 'a', long = "all", help = "Resume all paused operations")] + pub all: bool, + + #[arg(short = 'i', long = "id", help = "Specify ID of the operation to resume")] + pub id: Option, } diff --git a/src/main.rs b/src/main.rs index 77bbe12..d02671c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,24 +24,38 @@ fn print_version() { fn main() { let cli = Cli::parse(); + // Handle the version flag if cli.version { print_version(); return; } + // Handle the specified operation if let Some(operation) = cli.operation { match operation { Operations::Install(install) => { println!("Installing packages: {:?}", install.pkgs); + if install.force { + println!("Force installation enabled."); + } } Operations::Remove(remove) => { println!("Removing packages: {:?}", remove.pkgs); + if remove.yes { + println!("Automatic yes to prompts enabled."); + } } Operations::Search(search) => { println!("Searching packages: {:?}", search.terms); + if search.all { + println!("Searching all available packages."); + } } Operations::Query(query) => { println!("Querying packages: {:?}", query.terms); + if query.details { + println!("Detailed information requested."); + } } Operations::List => { println!("Listing packages"); @@ -54,6 +68,24 @@ fn main() { } Operations::AddRepo(add_repo) => { println!("Adding repository: {}", add_repo.repo); + if add_repo.update { + println!("Updating repository list."); + } + } + Operations::Downgrade(downgrade) => { + println!("Downgrading packages: {:?}", downgrade.pkgs); + if let Some(version) = downgrade.version { + println!("Downgrading to version: {}", version); + } + } + Operations::Resume(resume) => { + if resume.all { + println!("Resuming all paused operations."); + } else if let Some(id) = resume.id { + println!("Resuming operation with ID: {}", id); + } else { + println!("Resuming operation"); + } } } } else {