Fixed Cargo.toml & flake.nix, solved issue #6, added new warn(); helper function.

i18n
Michal 2 years ago
parent a82319cd3f
commit f1f41a86e0

@ -0,0 +1 @@
use flake

1
.gitignore vendored

@ -5,3 +5,4 @@ ame.exe
.idea .idea
result result
.DS_Store .DS_Store
.direnv

@ -5,6 +5,7 @@ authors = ["michal <michal@tar.black>", "axtlos <axtlos@tar.black>"]
edition = "2021" edition = "2021"
description = "A fast and efficient AUR helper" description = "A fast and efficient AUR helper"
license-file = "LICENSE.md" license-file = "LICENSE.md"
default-run = "ame"
[features] [features]
pkg-warner = [] pkg-warner = []

@ -22,7 +22,7 @@
]; ];
}; };
defaultPackage = packages.amethyst; packages.default = packages.amethyst;
apps.amethyst = utils.lib.mkApp { apps.amethyst = utils.lib.mkApp {
drv = packages.amethyst; drv = packages.amethyst;
@ -30,7 +30,7 @@
apps.default = apps.amethyst; apps.default = apps.amethyst;
devShell = pkgs.mkShell { devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
rustc rustc
cargo cargo

@ -13,6 +13,14 @@ pub fn info<S: ToString>(msg: S) {
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)
} }
#[allow(dead_code)]
pub fn warn<S: ToString>(msg: S) {
let a = msg.to_string();
let a = if internal::uwu_enabled() { uwu!(&a) } else { a };
println!("\x1b[2;22;33m!\x1b[0m \x1b[1;37m{}\x1b[0m", a)
}
pub fn crash<S: ToString>(msg: S, exit_code: AppExitCode) -> ! { pub fn crash<S: ToString>(msg: S, exit_code: AppExitCode) -> ! {
let a = msg.to_string(); let a = msg.to_string();
let a = if internal::uwu_enabled() { uwu!(&a) } else { a }; let a = if internal::uwu_enabled() { uwu!(&a) } else { a };

@ -6,7 +6,8 @@ use internal::commands::ShellCommand;
use internal::error::SilentUnwrap; use internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode; use crate::internal::exit_code::AppExitCode;
use crate::internal::{crash, info, init, log, sort, structs::Options}; #[allow(unused_imports)]
use crate::internal::{crash, warn, prompt, info, init, log, sort, structs::Options};
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

@ -3,7 +3,7 @@ use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode; use crate::internal::exit_code::AppExitCode;
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::{info, log, Options}; use crate::{info, log, prompt, Options};
pub fn upgrade(options: Options) { pub fn upgrade(options: Options) {
let verbosity = options.verbosity; let verbosity = options.verbosity;
@ -18,12 +18,23 @@ pub fn upgrade(options: Options) {
log("Upgrading repo packages".to_string()); log("Upgrading repo packages".to_string());
} }
ShellCommand::pacman() let pacman_result = ShellCommand::pacman()
.elevated() .elevated()
.args(pacman_args) .args(pacman_args)
.wait_success() .wait()
.silent_unwrap(AppExitCode::PacmanError); .silent_unwrap(AppExitCode::PacmanError);
if pacman_result.success() {
info("Successfully upgraded repo packages".to_string());
} else {
let cont = prompt("Failed to upgrade repo packages, continue to upgrading AUR packages?".to_string(), false);
if !cont {
info("Exiting".to_string());
std::process::exit(AppExitCode::PacmanError as i32);
}
}
if verbosity >= 1 { if verbosity >= 1 {
log("Upgrading AUR packages".to_string()); log("Upgrading AUR packages".to_string());
} }

Loading…
Cancel
Save