Added info function

i18n
Michal S 2 years ago
parent aac4a97419
commit 8f0540eb46
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -37,6 +37,10 @@ pub enum Operation {
#[clap(name = "query", aliases = & ["q", "qu", "l", "ls", "-Q"])]
Query(QueryArgs),
/// Gets info about a package
#[clap(name = "info", aliases = & ["inf", "in", "i", "-Qi"])]
Info(InfoArgs),
/// Upgrades locally installed packages to their latest versions
#[clap(name = "upgrade", aliases = & ["upg", "up", "u", "-Syu"])]
Upgrade(UpgradeArgs),
@ -104,6 +108,13 @@ pub struct QueryArgs {
pub repo: bool,
}
#[derive(Default, Debug, Clone, Parser)]
pub struct InfoArgs {
/// The name of the package(s) to get info on
#[clap(required = true)]
pub package: String,
}
#[derive(Default, Debug, Clone, Parser)]
pub struct UpgradeArgs {
/// Upgrades only repo/native packages

@ -6,7 +6,7 @@ use clap::Parser;
use internal::commands::ShellCommand;
use internal::error::SilentUnwrap;
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs, UpgradeArgs};
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs, UpgradeArgs, InfoArgs};
use crate::internal::exit_code::AppExitCode;
use crate::internal::{init, sort, start_sudoloop, structs::Options, detect};
@ -51,6 +51,7 @@ fn main() {
Operation::Remove(remove_args) => cmd_remove(remove_args, options),
Operation::Search(search_args) => cmd_search(search_args, options),
Operation::Query(query_args) => cmd_query(query_args),
Operation::Info(info_args) => cmd_info(info_args),
Operation::Upgrade(upgrade_args) => cmd_upgrade(upgrade_args, options),
Operation::Clean => {
info!("Removing orphaned packages");
@ -152,6 +153,14 @@ fn cmd_query(args: QueryArgs) {
}
}
fn cmd_info(args: InfoArgs) {
ShellCommand::pacman()
.arg("-Qi")
.arg(args.package)
.wait()
.silent_unwrap(AppExitCode::PacmanError);
}
fn cmd_upgrade(args: UpgradeArgs, options: Options) {
info!("Performing system upgrade");
operations::upgrade(options, args);

Loading…
Cancel
Save