replaced panic! and eprintln! with crash! and log!

reworked pkg-warner slightly
i18n
michal 2 years ago
parent 9e7df5d1b4
commit 041f8e21b2

@ -15,27 +15,32 @@ pkg-warner = []
[[bin]] [[bin]]
name = "apt" name = "apt"
path = "src/warn.rs" path = "src/bin/apt.rs"
required-features = [ "pkg-warner" ] required-features = [ "pkg-warner" ]
[[bin]] [[bin]]
name = "apt-get" name = "apt-get"
path = "src/warn.rs" path = "src/bin/apt-get.rs"
required-features = [ "pkg-warner" ] required-features = [ "pkg-warner" ]
[[bin]] [[bin]]
name = "dnf" name = "dnf"
path = "src/warn.rs" path = "src/bin/dnf.rs"
required-features = [ "pkg-warner" ]
[[bin]]
name = "eopkg"
path = "src/bin/eopkg.rs"
required-features = [ "pkg-warner" ] required-features = [ "pkg-warner" ]
[[bin]] [[bin]]
name = "yum" name = "yum"
path = "src/warn.rs" path = "src/bin/yum.rs"
required-features = [ "pkg-warner" ] required-features = [ "pkg-warner" ]
[[bin]] [[bin]]
name = "zypper" name = "zypper"
path = "src/warn.rs" path = "src/bin/zypper.rs"
required-features = [ "pkg-warner" ] required-features = [ "pkg-warner" ]
[profile.release] [profile.release]
@ -50,6 +55,5 @@ clap = { version = "2.34.0", default-features = false, features = [ "suggestions
regex = { version = "1.5.4", default-features = false, features = [ "std", "unicode-perl" ] } regex = { version = "1.5.4", default-features = false, features = [ "std", "unicode-perl" ] }
runas = "0.2.1" runas = "0.2.1"
rusqlite = { version = "0.26.3", default-features = false } rusqlite = { version = "0.26.3", default-features = false }
reqwest = { version = "0.11.7", default-features = false, features = [ "blocking", "json", "default-tls" ] } ureq = { version = "2.4.0", default-features = false, features = [ "native-tls", "json" ] }
serde = { version = "1.0.90", default-features = false, features = [ "derive", "serde_derive" ] } serde = { version = "1.0.90", default-features = false, features = [ "derive", "serde_derive" ] }
throbber = { version = "0.1.4", default-features = false }

@ -0,0 +1,14 @@
use std::env;
fn main() {
let arg = &env::args().collect::<Vec<String>>()[0];
println!(
"Sorry for the bother, we don't use \x1b[2;22;35m{}\x1b[0m on Crystal, we use \x1b[2;22;35mame\x1b[0m! Please use that instead!",
arg.split('/')
.collect::<Vec<&str>>()
.last()
.unwrap()
);
std::process::exit(0);
}

@ -0,0 +1,14 @@
use std::env;
fn main() {
let arg = &env::args().collect::<Vec<String>>()[0];
println!(
"Sorry for the bother, we don't use \x1b[2;22;35m{}\x1b[0m on Crystal, we use \x1b[2;22;35mame\x1b[0m! Please use that instead!",
arg.split('/')
.collect::<Vec<&str>>()
.last()
.unwrap()
);
std::process::exit(0);
}

@ -0,0 +1,14 @@
use std::env;
fn main() {
let arg = &env::args().collect::<Vec<String>>()[0];
println!(
"Sorry for the bother, we don't use \x1b[2;22;35m{}\x1b[0m on Crystal, we use \x1b[2;22;35mame\x1b[0m! Please use that instead!",
arg.split('/')
.collect::<Vec<&str>>()
.last()
.unwrap()
);
std::process::exit(0);
}

@ -0,0 +1,14 @@
use std::env;
fn main() {
let arg = &env::args().collect::<Vec<String>>()[0];
println!(
"Sorry for the bother, we don't use \x1b[2;22;35m{}\x1b[0m on Crystal, we use \x1b[2;22;35mame\x1b[0m! Please use that instead!",
arg.split('/')
.collect::<Vec<&str>>()
.last()
.unwrap()
);
std::process::exit(0);
}

@ -0,0 +1,14 @@
use std::env;
fn main() {
let arg = &env::args().collect::<Vec<String>>()[0];
println!(
"Sorry for the bother, we don't use \x1b[2;22;35m{}\x1b[0m on Crystal, we use \x1b[2;22;35mame\x1b[0m! Please use that instead!",
arg.split('/')
.collect::<Vec<&str>>()
.last()
.unwrap()
);
std::process::exit(0);
}

@ -1,5 +1,5 @@
use crate::internal::rpc::Package; use crate::internal::rpc::Package;
use crate::Options; use crate::{crash, log, Options};
use rusqlite::Connection; use rusqlite::Connection;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
@ -12,12 +12,13 @@ pub fn add(pkg: Package, options: Options) {
.expect("Couldn't connect to database"); .expect("Couldn't connect to database");
if options.verbosity >= 1 { if options.verbosity >= 1 {
eprintln!("Adding package {} to database", pkg.name); log(format!("Adding package {} to database", pkg.name));
} }
conn.execute("INSERT OR REPLACE INTO packages (name, version, description, depends, make_depends) VALUES (?1, ?2, ?3, ?4, ?5)", conn.execute("INSERT OR REPLACE INTO packages (name, version, description, depends, make_depends) VALUES (?1, ?2, ?3, ?4, ?5)",
[&pkg.name, &pkg.version, &pkg.description.unwrap_or_else(|| "No description found.".parse().unwrap()), &pkg.depends.join(" "), &pkg.make_depends.join(" ")] [&pkg.name, &pkg.version, &pkg.description.unwrap_or_else(|| "No description found.".parse().unwrap()), &pkg.depends.join(" "), &pkg.make_depends.join(" ")]
).unwrap_or_else(|e| { ).unwrap_or_else(|e| {
panic!("Failed adding package {} to the database: {}", pkg.name, e); crash(format!("Failed adding package {} to the database: {}", pkg.name, e), 1);
1
}); });
} }

@ -1,4 +1,4 @@
use crate::Options; use crate::{crash, log, Options};
use rusqlite::Connection; use rusqlite::Connection;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
@ -9,14 +9,14 @@ pub fn init(options: Options) {
let verbosity = options.verbosity; let verbosity = options.verbosity;
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Creating database at {}", &path); log(format!("Creating database at {}", &path));
} }
let conn = let conn =
Connection::open(dbpath).expect("Couldn't create database at ~/.local/share/ame/db.sqlite"); Connection::open(dbpath).expect("Couldn't create database at ~/.local/share/ame/db.sqlite");
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Populating database with table") log("Populating database with table".to_string());
} }
conn.execute( conn.execute(
@ -30,6 +30,7 @@ pub fn init(options: Options) {
[], [],
) )
.unwrap_or_else(|e| { .unwrap_or_else(|e| {
panic!("Couldn't initialise database: {}", e); crash(format!("Couldn't initialise database: {}", e), 1);
1
}); });
} }

@ -1,5 +1,5 @@
use crate::internal::rpc::Package; use crate::internal::rpc::Package;
use crate::Options; use crate::{log, Options};
use rusqlite::Connection; use rusqlite::Connection;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
@ -8,7 +8,7 @@ pub fn query(a: &str, options: Options) -> Vec<Package> {
let verbosity = options.verbosity; let verbosity = options.verbosity;
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Connecting to database"); log("Connecting to database".to_string());
} }
let conn = Connection::open(Path::new(&format!( let conn = Connection::open(Path::new(&format!(
@ -18,7 +18,7 @@ pub fn query(a: &str, options: Options) -> Vec<Package> {
.expect("Couldn't connect to database"); .expect("Couldn't connect to database");
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Querying database for input") log("Querying database for input".to_string());
} }
let mut rs = conn let mut rs = conn
@ -47,7 +47,7 @@ pub fn query(a: &str, options: Options) -> Vec<Package> {
.expect("Couldn't query database for packages"); .expect("Couldn't query database for packages");
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Retrieved results"); log("Retrieved results".to_string());
} }
let mut results: Vec<Package> = vec![]; let mut results: Vec<Package> = vec![];
@ -57,7 +57,7 @@ pub fn query(a: &str, options: Options) -> Vec<Package> {
} }
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Collected results") log("Collected results".to_string());
} }
results results

@ -1,4 +1,4 @@
use crate::Options; use crate::{log, Options};
use rusqlite::Connection; use rusqlite::Connection;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
@ -13,7 +13,7 @@ pub fn remove(pkg: &str, options: Options) {
let verbosity = options.verbosity; let verbosity = options.verbosity;
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Removing package {} from database", pkg); log(format!("Removing package {} from database", pkg));
} }
conn.execute( conn.execute(

@ -1,3 +1,4 @@
use crate::internal::strings::log;
use crate::Options; use crate::Options;
use regex::Regex; use regex::Regex;
@ -15,21 +16,8 @@ pub fn clean(a: &[String], options: Options) -> Vec<String> {
} }
} }
match verbosity { if verbosity >= 1 {
0 => {} log(format!("Cleaned: {:?}\nInto: {:?}", a, cleaned));
1 => {
eprintln!("Cleaned: {:?}\nInto: {:?}", a, cleaned);
}
_ => {
eprintln!("Cleaned:");
for b in a {
eprintln!("{}", b);
}
eprintln!("Into:");
for c in &cleaned {
eprintln!("{}", c);
}
}
} }
cleaned cleaned

@ -1,3 +1,4 @@
use crate::internal::strings::{crash, log};
use crate::Options; use crate::Options;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
@ -11,11 +12,14 @@ pub fn init(options: Options) {
match r { match r {
Ok(_) => { Ok(_) => {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Created path: {}/.local/share/ame", homedir); log(format!("Created path: {}/.local/share/ame", homedir));
} }
} }
Err(e) => { Err(e) => {
panic!("Couldn't create path: {}/.local/share/ame: {}", homedir, e); crash(
format!("Couldn't create path: {}/.local/share/ame: {}", homedir, e),
1,
);
} }
} }
} }
@ -29,11 +33,14 @@ pub fn init(options: Options) {
match r { match r {
Ok(_) => { Ok(_) => {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Created path: {}/.cache/ame", homedir); log(format!("Created path: {}/.cache/ame", homedir));
} }
} }
Err(e) => { Err(e) => {
panic!("Couldn't create path: {}/.cache/ame: {}", homedir, e); crash(
format!("Couldn't create path: {}/.cache/ame: {}", homedir, e),
1,
);
} }
} }
} }

@ -26,3 +26,7 @@ pub fn info(a: String) {
pub fn crash(a: String, b: i32) { pub fn crash(a: String, b: i32) {
strings::crash(a, b); strings::crash(a, b);
} }
pub fn log(a: String) {
strings::log(a);
}

@ -1,5 +1,3 @@
#![allow(dead_code)]
#[derive(serde::Deserialize, Debug, Clone)] #[derive(serde::Deserialize, Debug, Clone)]
pub struct Package { pub struct Package {
#[serde(rename = "Name")] #[serde(rename = "Name")]
@ -31,12 +29,13 @@ pub struct InfoResults {
pub const URL: &str = "https://aur.archlinux.org/"; pub const URL: &str = "https://aur.archlinux.org/";
pub fn rpcinfo(pkg: String) -> InfoResults { pub fn rpcinfo(pkg: String) -> InfoResults {
let res = reqwest::blocking::get(&format!( let res: SearchResults = ureq::get(&format!(
"https://aur.archlinux.org/rpc/?v=5&type=info&arg={}", "https://aur.archlinux.org/rpc/?v=5&type=info&arg={}",
pkg pkg
)) ))
.call()
.unwrap() .unwrap()
.json::<SearchResults>() .into_json()
.unwrap(); .unwrap();
if res.results.is_empty() { if res.results.is_empty() {
@ -53,11 +52,12 @@ pub fn rpcinfo(pkg: String) -> InfoResults {
} }
pub fn rpcsearch(pkg: String) -> SearchResults { pub fn rpcsearch(pkg: String) -> SearchResults {
reqwest::blocking::get(&format!( ureq::get(&format!(
"https://aur.archlinux.org/rpc/?v=5&type=search&arg={}", "https://aur.archlinux.org/rpc/?v=5&type=search&arg={}",
pkg pkg
)) ))
.call()
.unwrap() .unwrap()
.json() .into_json::<SearchResults>()
.unwrap() .unwrap()
} }

@ -1,3 +1,4 @@
use crate::internal::strings::log;
use crate::internal::{clean, rpc, structs}; use crate::internal::{clean, rpc, structs};
use crate::Options; use crate::Options;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
@ -10,18 +11,8 @@ pub fn sort(input: &[String], options: Options) -> structs::Sorted {
let a = clean(input, options); let a = clean(input, options);
match verbosity { if verbosity >= 1 {
0 => {} log(format!("Sorting: {:?}", a.join(" ")));
1 => {
eprintln!("Sorting:");
eprintln!("{:?}", a);
}
_ => {
eprintln!("Sorting:");
for b in &a {
eprintln!("{}", b);
}
}
} }
for b in a { for b in a {
@ -34,17 +25,17 @@ pub fn sort(input: &[String], options: Options) -> structs::Sorted {
if rpc::rpcinfo(b.to_string()).found { if rpc::rpcinfo(b.to_string()).found {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("{} found in AUR", b); log(format!("{} found in AUR", b));
} }
aur.push(b.to_string()); aur.push(b.to_string());
} else if let Some(0) = rs.code() { } else if let Some(0) = rs.code() {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("{} found in repos", b) log(format!("{} found in repos", b));
} }
repo.push(b.to_string()); repo.push(b.to_string());
} else { } else {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("{} not found", b); log(format!("{} not found", b));
} }
nf.push(b.to_string()); nf.push(b.to_string());
} }

@ -1,4 +1,5 @@
use std::process::exit; use std::process::exit;
use std::time::UNIX_EPOCH;
pub fn info(a: String) { pub fn info(a: String) {
println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a) println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a)
@ -8,3 +9,14 @@ pub fn crash(a: String, b: i32) {
println!("\x1b[2;22;31m❌\x1b[0m \x1b[1;91m{}\x1b[0m", a); println!("\x1b[2;22;31m❌\x1b[0m \x1b[1;91m{}\x1b[0m", a);
exit(b); exit(b);
} }
pub fn log(a: String) {
eprintln!(
"{} {}",
std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
a
);
}

@ -5,7 +5,7 @@ mod database;
mod internal; mod internal;
mod operations; mod operations;
use crate::internal::{info, init, sort, structs::Options}; use crate::internal::{crash, info, init, log, sort, structs::Options};
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand}; use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand};
use std::io; use std::io;
use std::process::exit; use std::process::exit;
@ -16,7 +16,7 @@ fn main() {
} }
if unsafe { geteuid() } == 0 { if unsafe { geteuid() } == 0 {
panic!("Running amethyst as root is disallowed as it can lead to system breakage. Instead, amethyst will prompt you when it needs superuser permissions") crash("Running amethyst as root is disallowed as it can lead to system breakage. Instead, amethyst will prompt you when it needs superuser permissions".to_string(), 1);
} }
fn build_app() -> App<'static, 'static> { fn build_app() -> App<'static, 'static> {
@ -152,10 +152,10 @@ fn main() {
operations::aur_install(sorted.aur, options); operations::aur_install(sorted.aur, options);
} }
if !sorted.nf.is_empty() { if !sorted.nf.is_empty() {
eprintln!( log(format!(
"Couldn't find packages: {} in repos or the AUR", "Couldn't find packages: {} in repos or the AUR",
sorted.nf.join(", ") sorted.nf.join(", ")
); ));
} }
exit(0); exit(0);
} }

@ -1,6 +1,6 @@
use crate::internal::crash; use crate::internal::crash;
use crate::internal::rpc::rpcinfo; use crate::internal::rpc::rpcinfo;
use crate::{info, Options}; use crate::{info, log, Options};
use std::env; use std::env;
use std::env::set_current_dir; use std::env::set_current_dir;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
@ -12,18 +12,9 @@ pub fn aur_install(a: Vec<String>, options: Options) {
let cachedir = format!("{}/.cache/ame/", env::var("HOME").unwrap()); let cachedir = format!("{}/.cache/ame/", env::var("HOME").unwrap());
let verbosity = options.verbosity; let verbosity = options.verbosity;
let noconfirm = options.noconfirm; let noconfirm = options.noconfirm;
match verbosity {
0 => {} if verbosity >= 1 {
1 => { log(format!("Installing from AUR: {:?}", &a));
eprintln!("Installing from AUR:");
eprintln!("{:?}", &a);
}
_ => {
eprintln!("Installing from AUR:");
for b in &a {
eprintln!("{:?}", b);
}
}
} }
info(format!("Installing packages {} from the AUR", a.join(", "))); info(format!("Installing packages {} from the AUR", a.join(", ")));
@ -38,7 +29,7 @@ pub fn aur_install(a: Vec<String>, options: Options) {
let pkg = &rpcres.package.as_ref().unwrap().name; let pkg = &rpcres.package.as_ref().unwrap().name;
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Cloning {} into cachedir", pkg); log(format!("Cloning {} into cachedir", pkg));
} }
info("Cloning package source".to_string()); info("Cloning package source".to_string());
@ -52,15 +43,15 @@ pub fn aur_install(a: Vec<String>, options: Options) {
.expect("Something has gone wrong"); .expect("Something has gone wrong");
if verbosity >= 1 { if verbosity >= 1 {
eprintln!( log(format!(
"Cloned {} into cachedir, moving on to resolving dependencies", "Cloned {} into cachedir, moving on to resolving dependencies",
pkg pkg
); ));
eprintln!( log(format!(
"Raw dependencies for package {} are:\n{:?}", "Raw dependencies for package {} are:\n{:?}",
pkg, pkg,
rpcres.package.as_ref().unwrap().depends.join(", ") rpcres.package.as_ref().unwrap().depends.join(", ")
) ));
} }
// dep sorting // dep sorting
@ -68,7 +59,10 @@ pub fn aur_install(a: Vec<String>, options: Options) {
let sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options); let sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options);
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Sorted dependencies for {} are:\n{:?}", pkg, &sorted) log(format!(
"Sorted dependencies for {} are:\n{:?}",
pkg, &sorted
));
} }
let newopts = Options { let newopts = Options {
@ -78,10 +72,13 @@ pub fn aur_install(a: Vec<String>, options: Options) {
}; };
if !sorted.nf.is_empty() { if !sorted.nf.is_empty() {
panic!( crash(
"Could not find dependencies {} for package {}, aborting", format!(
sorted.nf.join(", "), "Could not find dependencies {} for package {}, aborting",
pkg sorted.nf.join(", "),
pkg
),
1,
); );
} }

@ -1,4 +1,4 @@
use crate::{info, Options}; use crate::{info, log, Options};
pub fn install(mut a: Vec<String>, options: Options) { pub fn install(mut a: Vec<String>, options: Options) {
info(format!("Installing packages {} from repos", &a.join(", "))); info(format!("Installing packages {} from repos", &a.join(", ")));
@ -10,18 +10,8 @@ pub fn install(mut a: Vec<String>, options: Options) {
a.push("--asdeps".to_string()); a.push("--asdeps".to_string());
} }
let verbosity = options.verbosity; let verbosity = options.verbosity;
match verbosity { if verbosity >= 1 {
0 => {} log(format!("Installing from repos: {:?}", &b));
1 => {
eprintln!("Installing from repos:");
eprintln!("{:?}", &b);
}
_ => {
eprintln!("Installing from repos:");
for b in &a {
eprintln!("{:?}", b);
}
}
} }
let r = runas::Command::new("pacman") let r = runas::Command::new("pacman")
@ -33,7 +23,10 @@ pub fn install(mut a: Vec<String>, options: Options) {
if let Some(x) = r.code() { if let Some(x) = r.code() {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Installing packages: {:?} exited with code {}", &b, x) log(format!(
"Installing packages: {:?} exited with code {}",
&b, x
));
} }
} }
} }

@ -1,5 +1,5 @@
use crate::internal::rpc::rpcsearch; use crate::internal::rpc::rpcsearch;
use crate::Options; use crate::{log, Options};
use std::process::Command; use std::process::Command;
pub fn aur_search(a: &str, options: Options) { pub fn aur_search(a: &str, options: Options) {
@ -7,7 +7,10 @@ pub fn aur_search(a: &str, options: Options) {
let res = rpcsearch(a.to_string()); let res = rpcsearch(a.to_string());
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Found {} results for \"{}\" in AUR", res.resultcount, a); log(format!(
"Found {} resuls for \"{}\" in AUR",
res.resultcount, a
));
} }
for r in &res.results { for r in &res.results {
@ -33,11 +36,11 @@ pub fn repo_search(a: &str, options: Options) {
let str = String::from_utf8(rs.stdout).unwrap(); let str = String::from_utf8(rs.stdout).unwrap();
if verbosity >= 1 { if verbosity >= 1 {
eprintln!( log(format!(
"Found {} results for \"{}\" in repos", "Found {} results for \"{}\" in repos",
&str.split('\n').count() / 2, &str.split('\n').count() / 2,
&a &a
); ));
} }
print!("{}", str); print!("{}", str);

@ -1,4 +1,4 @@
use crate::Options; use crate::{log, Options};
use std::path::Path; use std::path::Path;
use std::{env, fs}; use std::{env, fs};
@ -8,18 +8,8 @@ pub fn uninstall(mut a: Vec<String>, options: Options) {
a.push("--noconfirm".to_string()); a.push("--noconfirm".to_string());
} }
let verbosity = options.verbosity; let verbosity = options.verbosity;
match verbosity { if verbosity >= 1 {
0 => {} log(format!("Uninstalling: {:?}", &b));
1 => {
eprintln!("Uninstalling:");
eprintln!("{:?}", &b);
}
_ => {
eprintln!("Uninstalling:");
for b in &a {
eprintln!("{}", b);
}
}
} }
let r = runas::Command::new("pacman") let r = runas::Command::new("pacman")
@ -30,7 +20,10 @@ pub fn uninstall(mut a: Vec<String>, options: Options) {
if let Some(x) = r.code() { if let Some(x) = r.code() {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Uninstalling packages: {:?} exited with code {}", &b, x) log(format!(
"Uninstalling packages: {:?} exited with code {}",
&b, x
));
} }
} }
@ -38,7 +31,7 @@ pub fn uninstall(mut a: Vec<String>, options: Options) {
crate::database::remove(&b, options); crate::database::remove(&b, options);
if Path::new(&format!("{}/.cache/ame/{}", env::var("HOME").unwrap(), b)).exists() { if Path::new(&format!("{}/.cache/ame/{}", env::var("HOME").unwrap(), b)).exists() {
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Old cache directory found, deleting") log("Old cache directory found, deleting".to_string());
} }
fs::remove_dir_all(Path::new(&format!( fs::remove_dir_all(Path::new(&format!(
"{}/.cache/ame/{}", "{}/.cache/ame/{}",

@ -1,6 +1,6 @@
use crate::internal::rpc::rpcinfo; use crate::internal::rpc::rpcinfo;
use crate::operations::aur_install::aur_install; use crate::operations::aur_install::aur_install;
use crate::Options; use crate::{log, Options};
use runas::Command; use runas::Command;
pub fn upgrade(options: Options) { pub fn upgrade(options: Options) {
@ -13,7 +13,7 @@ pub fn upgrade(options: Options) {
} }
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Upgrading repo packages") log("Upgrading repo packages".to_string());
} }
Command::new("pacman") Command::new("pacman")
@ -22,7 +22,7 @@ pub fn upgrade(options: Options) {
.expect("Something has gone wrong"); .expect("Something has gone wrong");
if verbosity >= 1 { if verbosity >= 1 {
eprintln!("Upgrading AUR packages") log("Upgrading AUR packages".to_string());
} }
let res = crate::database::query("\"%\"", options); let res = crate::database::query("\"%\"", options);

Loading…
Cancel
Save