From 2b7b4aa87876d92805757839d0d446063fd6b5e6 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 13:24:36 +0100 Subject: [PATCH 01/13] Spinners and better pacdiff --- Cargo.lock | 47 +++++++++++++++++++++++++++++++++++ Cargo.toml | 3 ++- src/internal/detect.rs | 38 +++++++++++++++++++--------- src/internal/utils.rs | 46 ++++++++++++++++++++++++++++++++++ src/operations/aur_install.rs | 5 ++-- src/operations/upgrade.rs | 7 +++++- 6 files changed, 130 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 633d63c..a238443 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,7 @@ dependencies = [ "regex", "rm_rf", "serde", + "spinoff", "ureq", ] @@ -252,6 +253,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matches" version = "0.1.9" @@ -447,6 +454,12 @@ dependencies = [ "stacker", ] +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + [[package]] name = "ryu" version = "1.0.11" @@ -517,6 +530,18 @@ dependencies = [ "serde", ] +[[package]] +name = "spinoff" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c139aa6a2b4ed01ef761dfd593eb5b02218dbf35a3a0f10940b72f5bfe70426" +dependencies = [ + "colored", + "maplit", + "once_cell", + "strum", +] + [[package]] name = "stacker" version = "0.1.15" @@ -536,6 +561,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "syn" version = "1.0.99" diff --git a/Cargo.toml b/Cargo.toml index aee3c3d..736946d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,4 +26,5 @@ ureq = { version = "2.4.0", default-features = false, features = [ "native-tls", serde = { version = "1.0.138", default-features = false, features = [ "derive", "serde_derive" ] } native-tls = { version = "0.2.10", default-features = false } libc = { version = "0.2.126", default-features = false } -rm_rf = { version = "0.6.2", default-features = false } \ No newline at end of file +rm_rf = { version = "0.6.2", default-features = false } +spinoff = { version = "0.5.3", default-features = false } \ No newline at end of file diff --git a/src/internal/detect.rs b/src/internal/detect.rs index 9553b56..b9b88dd 100644 --- a/src/internal/detect.rs +++ b/src/internal/detect.rs @@ -1,20 +1,22 @@ use crate::internal::commands::ShellCommand; use crate::internal::error::SilentUnwrap; use crate::internal::exit_code::AppExitCode; -use crate::{info, prompt, warn}; +use crate::{prompt, warn, spinner}; +use std::env; pub fn detect() { - info!("Scanning for pacnew files"); + // Start spinner + let sp = spinner!("Scanning for pacnew files"); let mut pacnew = vec![]; // Run `find` to find pacnew files and split by lines into a vec - let find = std::process::Command::new("sudo") - .arg("pacdiff") - .arg("-f") - .output() - .unwrap(); - let find_lines = std::str::from_utf8(&find.stdout).unwrap().split('\n'); + let find = ShellCommand::pacdiff() + .args(&["-o", "-f"]) + .elevated() + .wait_with_output() + .silent_unwrap(AppExitCode::PacmanError); + let find_lines = find.stdout.split('\n'); for line in find_lines { if !line.is_empty() { pacnew.push(line.to_string()); @@ -23,16 +25,28 @@ pub fn detect() { // If pacnew files are found, warn the user and prompt to pacdiff if !pacnew.is_empty() { - let choice = prompt!(default false, "It appears that at least one program you have installed / upgraded has installed a .pacnew/.pacsave config file. Would you like to run pacdiff to deal with this? You can always deal with this later by running `sudo pacdiff`"); + sp.stop_bold("It appears that at least one program you have installed / upgraded has installed a .pacnew/.pacsave config file. These are created when you have modified a program's configuration, and a package upgrade could not automatically merge the new file."); + + let choice = prompt!(default false, "Would you like to run pacdiff to deal with this? You can always deal with this later by running `sudo pacdiff`"); if choice { - warn!("Unless you've set an alternative using the DIFFPROG environment variable, pacdiff uses `vimdiff` by default to edit files for merging. Make sure you know how to exit vim before proceeding"); - let cont = prompt!(default false, "Continue?"); - if cont { + if env::var("PACDIFF_WARNING").unwrap_or_else(|_| "1".to_string()) != "0" { + warn!("Pacdiff uses `vimdiff` by default to edit files for merging. Make sure you know how to exit vim before proceeding!"); + warn!("You can surpress this warning in the future by setting the `PACDIFF_WARNING` environment variable to `0`"); + let cont = prompt!(default false, "Continue?"); + if cont { + ShellCommand::pacdiff() + .elevated() + .wait() + .silent_unwrap(AppExitCode::PacmanError); + } + } else { ShellCommand::pacdiff() .elevated() .wait() .silent_unwrap(AppExitCode::PacmanError); } } + } else { + sp.stop_bold("No pacnew files found"); } } diff --git a/src/internal/utils.rs b/src/internal/utils.rs index eadb0ec..ee04076 100644 --- a/src/internal/utils.rs +++ b/src/internal/utils.rs @@ -50,6 +50,13 @@ macro_rules! prompt { } } +#[macro_export] +macro_rules! spinner { + ($($arg:tt)+) => { + $crate::internal::utils::spinner_fn(format!($($arg)+)) + } +} + pub fn log_info(msg: S) { let msg = msg.to_string(); let msg = if internal::uwu_enabled() { @@ -137,3 +144,42 @@ pub fn prompt_yn(question: S, default_true: bool) -> bool { default_true } } + +pub struct Spinner { + spinner: spinoff::Spinner, +} + +impl Spinner { + pub fn stop_bold(self, text: &str) { + let text = if internal::uwu_enabled() { + uwu!(text) + } else { + text.to_string() + }; + + let symbol = Box::new(format!("{}", OK_SYMBOL.purple())); + let text = Box::new(format!("{}", text.bold())); + + let symbol: &'static str = Box::leak(symbol); + let text: &'static str = Box::leak(text); + + self.spinner.stop_and_persist(symbol, text); + } +} + +pub fn spinner_fn(text: String) -> Spinner { + let text = if internal::uwu_enabled() { + uwu!(&text) + } else { + text + }; + Spinner { + spinner: spinoff::Spinner::new( + spinoff::Spinners::Line, + format!("{}", + text.bold()), + spinoff::Color::Magenta, + ) + } +} + diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index f8ed002..87b4729 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -67,9 +67,10 @@ pub fn aur_install(a: Vec, options: Options) { } // Sort dependencies and makedepends - log!("Sorting dependencies"); + if verbosity >= 1 { + log!("Sorting dependencies and makedepends"); + } let sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options); - log!("Sorting make dependencies"); let md_sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().make_depends, options); diff --git a/src/operations/upgrade.rs b/src/operations/upgrade.rs index 0de1221..6c5c9eb 100644 --- a/src/operations/upgrade.rs +++ b/src/operations/upgrade.rs @@ -4,7 +4,7 @@ use crate::internal::error::SilentUnwrap; use crate::internal::exit_code::AppExitCode; use crate::internal::rpc::rpcinfo; use crate::operations::aur_install::aur_install; -use crate::{info, log, prompt, Options}; +use crate::{info, log, prompt, Options, spinner}; #[derive(Debug)] struct QueriedPackage { @@ -53,6 +53,9 @@ pub fn upgrade(options: Options) { log!("Checking AUR upgrades..."); } + // Start spinner + let sp = spinner!("Checking AUR upgrades..."); + // List non-native packages using `pacman -Qm` and collect to a Vec let non_native = ShellCommand::pacman() .arg("-Qm") @@ -101,6 +104,8 @@ pub fn upgrade(options: Options) { } } + sp.stop_bold("Finished!"); + // If vector isn't empty, prompt to install AUR packages from vector, effectively upgrading if !aur_upgrades.is_empty() { let cont = prompt!(default false, From c4ecfc2d78e94719eaf28248ade486a92e5ffd8b Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 13:43:16 +0100 Subject: [PATCH 02/13] Split Upgrade into AUR/repo --- src/args.rs | 21 ++++- src/internal/initialise.rs | 14 --- src/main.rs | 18 ++-- src/operations/upgrade.rs | 178 ++++++++++++++++++++----------------- 4 files changed, 126 insertions(+), 105 deletions(-) diff --git a/src/args.rs b/src/args.rs index f3d760e..87d7e91 100644 --- a/src/args.rs +++ b/src/args.rs @@ -15,7 +15,7 @@ pub struct Args { pub no_confirm: bool, /// Loops sudo in the background to ensure it doesn't time out during long builds - #[clap(long = "sudoloop")] + #[clap(long = "sudoloop", global = true)] pub sudoloop: bool, } @@ -39,16 +39,20 @@ pub enum Operation { /// Upgrades locally installed packages to their latest versions #[clap(name = "upgrade", aliases = & ["upg", "up", "u", "-Syu"])] - Upgrade, + Upgrade(UpgradeArgs), /// Removes all orphaned packages #[clap(name = "clean", aliases = & ["cln", "cl", "-Sc"])] Clean, + + /// Runs pacdiff + #[clap(name = "diff", aliases = & ["dif", "di", "-d"])] + Diff, } impl Default for Operation { fn default() -> Self { - Self::Upgrade + Self::Upgrade(UpgradeArgs::default()) } } @@ -97,3 +101,14 @@ pub struct QueryArgs { #[clap(long, short, from_global)] pub repo: bool, } + +#[derive(Default, Debug, Clone, Parser)] +pub struct UpgradeArgs { + /// Upgrades only repo/native packages + #[clap(long, short)] + pub repo: bool, + + /// Upgrades only from the AUR + #[clap(long, short)] + pub aur: bool, +} diff --git a/src/internal/initialise.rs b/src/internal/initialise.rs index bfafcbd..a89385c 100644 --- a/src/internal/initialise.rs +++ b/src/internal/initialise.rs @@ -8,20 +8,6 @@ pub fn init(options: Options) { let verbosity = options.verbosity; let homedir = env::var("HOME").unwrap(); - // Initialise stateful directory - if !Path::new(&format!("{}/.local/share/ame", homedir)).exists() { - if verbosity >= 1 { - log!("Initialising stateful directory"); - } - std::fs::create_dir_all(format!("{}/.local/share/ame", homedir)).unwrap_or_else(|e| { - crash!( - AppExitCode::FailedCreatingPaths, - "Failed to create stateful directory: {}", - e - ); - }); - } - // If cache path doesn't exist, create it, if it does, delete it and recreate it if !Path::new(&format!("{}/.cache/ame/", homedir)).exists() { if verbosity >= 1 { diff --git a/src/main.rs b/src/main.rs index 670b3e0..3f517e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,9 +6,9 @@ use clap::Parser; use internal::commands::ShellCommand; use internal::error::SilentUnwrap; -use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs}; +use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs, UpgradeArgs}; use crate::internal::exit_code::AppExitCode; -use crate::internal::{init, sort, start_sudoloop, structs::Options}; +use crate::internal::{init, sort, start_sudoloop, structs::Options, detect}; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; @@ -51,14 +51,15 @@ 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::Upgrade => { - info!("Performing system upgrade"); - operations::upgrade(options); - } + Operation::Upgrade(upgrade_args) => cmd_upgrade(upgrade_args, options), Operation::Clean => { info!("Removing orphaned packages"); operations::clean(options); } + Operation::Diff => { + info!("Running pacdiff"); + detect(); + } } } @@ -150,3 +151,8 @@ fn cmd_query(args: QueryArgs) { .silent_unwrap(AppExitCode::PacmanError); } } + +fn cmd_upgrade(args: UpgradeArgs, options: Options) { + info!("Performing system upgrade"); + operations::upgrade(options, args); +} diff --git a/src/operations/upgrade.rs b/src/operations/upgrade.rs index 6c5c9eb..ebfe508 100644 --- a/src/operations/upgrade.rs +++ b/src/operations/upgrade.rs @@ -3,6 +3,7 @@ use crate::internal::detect; use crate::internal::error::SilentUnwrap; use crate::internal::exit_code::AppExitCode; use crate::internal::rpc::rpcinfo; +use crate::args::UpgradeArgs; use crate::operations::aur_install::aur_install; use crate::{info, log, prompt, Options, spinner}; @@ -12,111 +13,124 @@ struct QueriedPackage { pub version: String, } -pub fn upgrade(options: Options) { +pub fn upgrade(options: Options, args: UpgradeArgs) { // Initialise variables let verbosity = options.verbosity; let noconfirm = options.noconfirm; - // Build pacman args - let mut pacman_args = vec!["-Syu"]; - if noconfirm { - pacman_args.push("--noconfirm"); - } - - if verbosity >= 1 { - log!("Upgrading repo packages"); - } + let args = if !args.aur && !args.repo { + UpgradeArgs { + aur: true, + repo: true, + } + } else { + args + }; + + if args.repo { + // Build pacman args + let mut pacman_args = vec!["-Syu"]; + if noconfirm { + pacman_args.push("--noconfirm"); + } - // Upgrade repo packages - let pacman_result = ShellCommand::pacman() - .elevated() - .args(pacman_args) - .wait() - .silent_unwrap(AppExitCode::PacmanError); + if verbosity >= 1 { + log!("Upgrading repo packages"); + } - if pacman_result.success() { - // If pacman was successful, notify user - info!("Successfully upgraded repo packages"); - } else { - // Otherwise, prompt user whether to continue - let cont = prompt!(default false, + // Upgrade repo packages + let pacman_result = ShellCommand::pacman() + .elevated() + .args(pacman_args) + .wait() + .silent_unwrap(AppExitCode::PacmanError); + + if pacman_result.success() { + // If pacman was successful, notify user + info!("Successfully upgraded repo packages"); + } else { + // Otherwise, prompt user whether to continue + let cont = prompt!(default false, "Failed to upgrade repo packages, continue to upgrading AUR packages?", ); - if !cont { - // If user doesn't want to continue, break - info!("Exiting"); - std::process::exit(AppExitCode::PacmanError as i32); + if !cont { + // If user doesn't want to continue, break + info!("Exiting"); + std::process::exit(AppExitCode::PacmanError as i32); + } } } - if verbosity >= 1 { - log!("Checking AUR upgrades..."); - } - - // Start spinner - let sp = spinner!("Checking AUR upgrades..."); - - // List non-native packages using `pacman -Qm` and collect to a Vec - let non_native = ShellCommand::pacman() - .arg("-Qm") - .args(&["--color", "never"]) - .wait_with_output() - .silent_unwrap(AppExitCode::PacmanError); - - // Collect by lines to a Vec - let mut non_native = non_native.stdout.split('\n').collect::>(); - - // Remove last element, which is an empty line - non_native.pop(); - - // Parse non-native packages into a Vec - let mut parsed_non_native: Vec = vec![]; - for pkg in non_native { - // Split by space - let split = pkg.split(' ').collect::>(); + if args.aur { if verbosity >= 1 { - log!("{:?}", split); + log!("Checking AUR upgrades..."); } - // Create QueriedPackage and push it to parsed_non_native - let name = split[0].to_string(); - let version = split[1].to_string(); - parsed_non_native.push(QueriedPackage { name, version }); - } - - if verbosity >= 1 { - log!("{:?}", &parsed_non_native); - } - // Check if AUR package versions are the same as installed - let mut aur_upgrades = vec![]; - for pkg in parsed_non_native { - // Query AUR - let rpc_result = rpcinfo((&*pkg.name).to_string()); + // Start spinner + let sp = spinner!("Checking AUR upgrades..."); + + // List non-native packages using `pacman -Qm` and collect to a Vec + let non_native = ShellCommand::pacman() + .arg("-Qm") + .args(&["--color", "never"]) + .wait_with_output() + .silent_unwrap(AppExitCode::PacmanError); + + // Collect by lines to a Vec + let mut non_native = non_native.stdout.split('\n').collect::>(); + + // Remove last element, which is an empty line + non_native.pop(); + + // Parse non-native packages into a Vec + let mut parsed_non_native: Vec = vec![]; + for pkg in non_native { + // Split by space + let split = pkg.split(' ').collect::>(); + if verbosity >= 1 { + log!("{:?}", split); + } + // Create QueriedPackage and push it to parsed_non_native + let name = split[0].to_string(); + let version = split[1].to_string(); + parsed_non_native.push(QueriedPackage { name, version }); + } - if !rpc_result.found { - // If package not found, skip - continue; + if verbosity >= 1 { + log!("{:?}", &parsed_non_native); } - // If versions differ, push to a vector - if rpc_result.package.unwrap().version != pkg.version { - aur_upgrades.push(pkg.name); + // Check if AUR package versions are the same as installed + let mut aur_upgrades = vec![]; + for pkg in parsed_non_native { + // Query AUR + let rpc_result = rpcinfo((&*pkg.name).to_string()); + + if !rpc_result.found { + // If package not found, skip + continue; + } + + // If versions differ, push to a vector + if rpc_result.package.unwrap().version != pkg.version { + aur_upgrades.push(pkg.name); + } } - } - sp.stop_bold("Finished!"); + sp.stop_bold("Finished!"); - // If vector isn't empty, prompt to install AUR packages from vector, effectively upgrading - if !aur_upgrades.is_empty() { - let cont = prompt!(default false, + // If vector isn't empty, prompt to install AUR packages from vector, effectively upgrading + if !aur_upgrades.is_empty() { + let cont = prompt!(default false, "Found AUR packages {} have new versions available, upgrade?", aur_upgrades.join(", "), ); - if cont { - aur_install(aur_upgrades, options); - }; - } else { - info!("No upgrades available for installed AUR packages"); + if cont { + aur_install(aur_upgrades, options); + }; + } else { + info!("No upgrades available for installed AUR packages"); + } } // Check for .pacnew files From aac4a9741900aba0ae693bd0e8600785d9780b48 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 14:06:22 +0100 Subject: [PATCH 03/13] Fixed circular AUR dependencies --- src/args.rs | 2 ++ src/operations/aur_install.rs | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/args.rs b/src/args.rs index 87d7e91..1a97eb0 100644 --- a/src/args.rs +++ b/src/args.rs @@ -63,9 +63,11 @@ pub struct InstallArgs { pub packages: Vec, /// Installs only from the AUR + #[clap(long, short)] pub aur: bool, /// Install the packages from the pacman-defined repositories + #[clap(long, short)] pub repo: bool, } diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index 87b4729..a8b0de9 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -21,6 +21,7 @@ pub fn aur_install(a: Vec, options: Options) { log!("Installing from AUR: {:?}", &a); } + info!("Installing packages {} from the AUR", a.join(", ")); for package in a { @@ -70,8 +71,8 @@ pub fn aur_install(a: Vec, options: Options) { if verbosity >= 1 { log!("Sorting dependencies and makedepends"); } - let sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options); - let md_sorted = + let mut sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options); + let mut md_sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().make_depends, options); if verbosity >= 1 { @@ -86,6 +87,28 @@ pub fn aur_install(a: Vec, options: Options) { asdeps: true, }; + // Get a list of installed packages + let installed = ShellCommand::pacman() + .elevated() + .args(&["-Qq"]) + .wait_with_output() + .silent_unwrap(AppExitCode::PacmanError) + .stdout + .split_whitespace() + .collect::>() + .iter().map(|s| s.to_string()) + .collect::>(); + + // Remove installed packages from sorted dependencies and makedepends + if verbosity >= 1 { + log!("Removing installed packages from sorted dependencies and makedepends"); + } + sorted.aur.retain(|x| !installed.contains(x)); + sorted.repo.retain(|x| !installed.contains(x)); + + md_sorted.aur.retain(|x| !installed.contains(x)); + md_sorted.repo.retain(|x| !installed.contains(x)); + // If dependencies are not found in AUR or repos, crash if !sorted.nf.is_empty() || !md_sorted.nf.is_empty() { crash!( @@ -144,15 +167,19 @@ pub fn aur_install(a: Vec, options: Options) { // Install dependencies and makedepends if !sorted.repo.is_empty() { crate::operations::install(sorted.repo, newopts); - crate::operations::install(md_sorted.repo, newopts); } if !sorted.aur.is_empty() { crate::operations::aur_install(sorted.aur, newopts); + } + if !md_sorted.repo.is_empty() { + crate::operations::install(md_sorted.repo, newopts); + } + if !md_sorted.aur.is_empty() { crate::operations::aur_install(md_sorted.aur, newopts); } // Build makepkg args - let mut makepkg_args = vec!["-rsci", "--skippgp"]; + let mut makepkg_args = vec!["-rsci", "--skippgp", "--needed"]; if options.asdeps { makepkg_args.push("--asdeps") } From 8f0540eb46bbd59652618693e698c9bb13a746f3 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 14:11:05 +0100 Subject: [PATCH 04/13] Added info function --- src/args.rs | 11 +++++++++++ src/main.rs | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/args.rs b/src/args.rs index 1a97eb0..c9fde29 100644 --- a/src/args.rs +++ b/src/args.rs @@ -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 diff --git a/src/main.rs b/src/main.rs index 3f517e0..3e80da8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); From 7b37173774acf1db08bf5eb4c2f3f17af5a12da7 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 14:11:26 +0100 Subject: [PATCH 05/13] Ver bump --- Cargo.toml | 2 +- PKGBUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 736946d..8dd7ddf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "Amethyst" -version = "3.4.0" +version = "3.5.0" authors = ["michal ", "axtlos "] edition = "2021" description = "A fast and efficient AUR helper" diff --git a/PKGBUILD b/PKGBUILD index 2e038c0..4ef0dfe 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,7 +3,7 @@ # Developer: Michal S pkgname=amethyst -pkgver=3.4.0 +pkgver=3.5.0 pkgrel=1 pkgdesc="A fast and efficient AUR helper" arch=('x86_64') From 324e38814d36c118569acef57b77eb741fa3d2a0 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 14:13:55 +0100 Subject: [PATCH 06/13] README.md update --- Cargo.lock | 2 +- README.md | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a238443..eb77f6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "Amethyst" -version = "3.4.0" +version = "3.5.0" dependencies = [ "clap", "colored", diff --git a/README.md b/README.md index c24707d..49ec745 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,12 @@ Tested on latest Cargo (1.60.0-nightly) - ~~Bugfixes, bugfixes, bugfixes!~~~ #### v3.5.0 -- Implement some sort of spinner for longer operations +- ~~Implement some sort of spinner for longer operations~~ +- ~~Fix circular AUR dependency bug~~ +- ~~Better wording for Pacdiff issue and option to mute~~ + +#### v3.6.0 (I need to stop pushing these back) - Allow editing of PKGBUILDs before install -- Allow to choose provider of package - Highlight optdepends at the end of an install operation