|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
use args::{Args, GenCompArgs, InfoArgs};
|
|
|
|
|
use args::{Args, GenCompArgs};
|
|
|
|
|
use builder::pacman::{PacmanColor, PacmanQueryBuilder};
|
|
|
|
|
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};
|
|
|
|
|
use crate::interact::page_string;
|
|
|
|
|
use crate::internal::detect;
|
|
|
|
|
use crate::internal::exit_code::AppExitCode;
|
|
|
|
@ -14,7 +14,6 @@ use crate::logging::get_logger;
|
|
|
|
|
use crate::logging::Printable;
|
|
|
|
|
|
|
|
|
|
use clap_complete::{Generator, Shell};
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::str::FromStr;
|
|
|
|
|
|
|
|
|
|
mod args;
|
|
|
|
@ -49,7 +48,14 @@ async fn main() {
|
|
|
|
|
match args.subcommand.unwrap_or_default() {
|
|
|
|
|
Operation::Install(install_args) => cmd_install(install_args, options).await,
|
|
|
|
|
Operation::Remove(remove_args) => cmd_remove(remove_args, options).await,
|
|
|
|
|
Operation::Search(search_args) => cmd_search(search_args, options).await,
|
|
|
|
|
Operation::Search(search_args) => {
|
|
|
|
|
let args = InstallArgs {
|
|
|
|
|
search: true,
|
|
|
|
|
..search_args
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cmd_install(args, options).await;
|
|
|
|
|
}
|
|
|
|
|
Operation::Query(query_args) => cmd_query(query_args).await,
|
|
|
|
|
Operation::Upgrade(upgrade_args) => {
|
|
|
|
|
tracing::info!("Performing system upgrade");
|
|
|
|
@ -59,7 +65,6 @@ async fn main() {
|
|
|
|
|
tracing::info!("Removing orphaned packages");
|
|
|
|
|
operations::clean(options).await;
|
|
|
|
|
}
|
|
|
|
|
Operation::Info(info_args) => cmd_info(info_args).await,
|
|
|
|
|
Operation::GenComp(gen_args) => cmd_gencomp(&gen_args),
|
|
|
|
|
Operation::Diff => todo!(),
|
|
|
|
|
}
|
|
|
|
@ -69,37 +74,40 @@ async fn main() {
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
|
async fn cmd_install(args: InstallArgs, options: Options) {
|
|
|
|
|
let packages = args.packages;
|
|
|
|
|
|
|
|
|
|
let arg1 = env::args().collect::<Vec<String>>()[1].clone();
|
|
|
|
|
let both = !args.aur && arg1 != "-Sa" && arg1 != "-Sr";
|
|
|
|
|
let aur = args.aur || arg1 == "-Sa";
|
|
|
|
|
let repo = args.repo || arg1 == "-Sr";
|
|
|
|
|
|
|
|
|
|
if repo {
|
|
|
|
|
operations::install(packages, options).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if aur {
|
|
|
|
|
operations::aur_install(packages, options).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let packages = &args.packages;
|
|
|
|
|
let both = !args.aur && !args.repo;
|
|
|
|
|
|
|
|
|
|
if both {
|
|
|
|
|
let sorted = sort(&packages, options).await;
|
|
|
|
|
if !sorted.nf.is_empty() {
|
|
|
|
|
crash!(
|
|
|
|
|
AppExitCode::PacmanError,
|
|
|
|
|
"Couldn't find packages: {} in repos or the AUR",
|
|
|
|
|
sorted.nf.join(", ")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if !sorted.repo.is_empty() {
|
|
|
|
|
operations::install(sorted.repo, options).await;
|
|
|
|
|
match args.search {
|
|
|
|
|
true => {
|
|
|
|
|
cmd_search(args, options).await;
|
|
|
|
|
}
|
|
|
|
|
if !sorted.aur.is_empty() {
|
|
|
|
|
operations::aur_install(sorted.aur, options).await;
|
|
|
|
|
false => {
|
|
|
|
|
if args.repo && !args.aur {
|
|
|
|
|
operations::install(packages.to_vec(), options).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if args.aur && !args.repo {
|
|
|
|
|
operations::aur_install(packages.to_vec(), options).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if both {
|
|
|
|
|
let sorted = sort(packages, options).await;
|
|
|
|
|
if !sorted.nf.is_empty() {
|
|
|
|
|
crash!(
|
|
|
|
|
AppExitCode::PacmanError,
|
|
|
|
|
"Couldn't find packages: {} in repos or the AUR",
|
|
|
|
|
sorted.nf.join(", ")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if !sorted.repo.is_empty() {
|
|
|
|
|
operations::install(sorted.repo, options).await;
|
|
|
|
|
}
|
|
|
|
|
if !sorted.aur.is_empty() {
|
|
|
|
|
operations::aur_install(sorted.aur, options).await;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -112,22 +120,18 @@ async fn cmd_remove(args: RemoveArgs, options: Options) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
|
async fn cmd_search(args: SearchArgs, options: Options) {
|
|
|
|
|
let query_string = args.search;
|
|
|
|
|
async fn cmd_search(args: InstallArgs, options: Options) {
|
|
|
|
|
let query_string = args.packages.join(" ");
|
|
|
|
|
let both = !args.aur && !args.repo;
|
|
|
|
|
|
|
|
|
|
let mut results = Vec::new();
|
|
|
|
|
|
|
|
|
|
let arg1 = env::args().collect::<Vec<String>>()[1].clone();
|
|
|
|
|
let both = !args.aur && arg1 != "-Ssa" && arg1 != "-Ssr";
|
|
|
|
|
let aur = args.aur || arg1 == "-Ssa" || both;
|
|
|
|
|
let repo = args.repo || arg1 == "-Ssr" || both;
|
|
|
|
|
|
|
|
|
|
if repo {
|
|
|
|
|
if args.repo || both {
|
|
|
|
|
tracing::info!("Searching repos for {}", &query_string);
|
|
|
|
|
let res = operations::search(&query_string, options).await;
|
|
|
|
|
results.extend(res);
|
|
|
|
|
}
|
|
|
|
|
if aur {
|
|
|
|
|
if args.aur || both {
|
|
|
|
|
tracing::info!("Searching AUR for {}", &query_string);
|
|
|
|
|
let res = operations::aur_search(&query_string, args.by, options).await;
|
|
|
|
|
results.extend(res);
|
|
|
|
@ -158,12 +162,9 @@ async fn cmd_search(args: SearchArgs, options: Options) {
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
|
async fn cmd_query(args: QueryArgs) {
|
|
|
|
|
let arg1 = env::args().collect::<Vec<String>>()[1].clone();
|
|
|
|
|
let both = !args.aur && arg1 != "-Qa" && arg1 != "-Qr";
|
|
|
|
|
let aur = args.aur || arg1 == "-Qa" || both;
|
|
|
|
|
let repo = args.repo || arg1 == "-Qr" || both;
|
|
|
|
|
let both = !args.aur && !args.repo && args.info.is_none();
|
|
|
|
|
|
|
|
|
|
if repo {
|
|
|
|
|
if args.repo {
|
|
|
|
|
tracing::info!("Installed Repo Packages: ");
|
|
|
|
|
PacmanQueryBuilder::native()
|
|
|
|
|
.color(PacmanColor::Always)
|
|
|
|
@ -171,7 +172,8 @@ async fn cmd_query(args: QueryArgs) {
|
|
|
|
|
.await
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
}
|
|
|
|
|
if aur {
|
|
|
|
|
|
|
|
|
|
if args.aur {
|
|
|
|
|
tracing::info!("Installed AUR Packages: ");
|
|
|
|
|
PacmanQueryBuilder::foreign()
|
|
|
|
|
.color(PacmanColor::Always)
|
|
|
|
@ -179,6 +181,7 @@ async fn cmd_query(args: QueryArgs) {
|
|
|
|
|
.await
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if both {
|
|
|
|
|
tracing::info!("Installed Packages: ");
|
|
|
|
|
PacmanQueryBuilder::all()
|
|
|
|
@ -187,15 +190,14 @@ async fn cmd_query(args: QueryArgs) {
|
|
|
|
|
.await
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
|
async fn cmd_info(args: InfoArgs) {
|
|
|
|
|
PacmanQueryBuilder::info()
|
|
|
|
|
.package(args.package)
|
|
|
|
|
.query()
|
|
|
|
|
.await
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
if let Some(info) = args.info {
|
|
|
|
|
PacmanQueryBuilder::info()
|
|
|
|
|
.package(info)
|
|
|
|
|
.query()
|
|
|
|
|
.await
|
|
|
|
|
.silent_unwrap(AppExitCode::PacmanError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
|