prettifying

i18n
michal 2 years ago
parent f7f3a3e866
commit 9e7df5d1b4

@ -1,19 +1,55 @@
[package]
name = "Amethyst"
version = "3.0.0"
authors = [ "jnats <michal@tar.black>", "axtlos <axtlos@tar.black>" ]
authors = [ "michal <michal@tar.black>", "axtlos <axtlos@tar.black>" ]
edition = "2021"
description = "A fast and efficient aur helper."
description = "A fast and efficient AUR helper."
license-file = "LICENSE.md"
[[bin]]
name = "ame"
path = "src/main.rs"
[features]
pkg-warner = []
[[bin]]
name = "apt"
path = "src/warn.rs"
required-features = [ "pkg-warner" ]
[[bin]]
name = "apt-get"
path = "src/warn.rs"
required-features = [ "pkg-warner" ]
[[bin]]
name = "dnf"
path = "src/warn.rs"
required-features = [ "pkg-warner" ]
[[bin]]
name = "yum"
path = "src/warn.rs"
required-features = [ "pkg-warner" ]
[[bin]]
name = "zypper"
path = "src/warn.rs"
required-features = [ "pkg-warner" ]
[profile.release]
incremental = true
debug = true
lto = "fat"
codegen-units = 1
[dependencies]
clap = { version = "2.34.0", default-features = false, features = [ "suggestions"] }
regex = { version = "1.5.4", default-features = false, features = [ "std" ] }
mimalloc = { version = "0.1.27", default-features = false }
clap = { version = "2.34.0", default-features = false, features = [ "suggestions" ] }
regex = { version = "1.5.4", default-features = false, features = [ "std", "unicode-perl" ] }
runas = "0.2.1"
rusqlite = { version = "0.26.3", default-features = false }
reqwest = { version = "0.11.7", default-features = false, features = [ "blocking", "json", "default-tls" ] }
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 }

@ -4,6 +4,7 @@ mod clean;
mod initialise;
pub mod rpc;
mod sort;
mod strings;
pub mod structs;
pub fn sort(a: &[String], options: Options) -> structs::Sorted {
@ -17,3 +18,11 @@ pub fn clean(a: &[String], options: Options) -> Vec<String> {
pub fn init(options: Options) {
initialise::init(options);
}
pub fn info(a: String) {
strings::info(a);
}
pub fn crash(a: String, b: i32) {
strings::crash(a, b);
}

@ -0,0 +1,10 @@
use std::process::exit;
pub fn info(a: String) {
println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a)
}
pub fn crash(a: String, b: i32) {
println!("\x1b[2;22;31m❌\x1b[0m \x1b[1;91m{}\x1b[0m", a);
exit(b);
}

@ -1,8 +1,11 @@
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
mod database;
mod internal;
mod operations;
use crate::internal::{init, sort, structs::Options};
use crate::internal::{info, init, sort, structs::Options};
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand};
use std::io;
use std::process::exit;
@ -137,6 +140,11 @@ fn main() {
let packages = collect_matches(&matches);
let sorted = sort(&packages, options);
info(format!(
"Attempting to install packages: {}",
packages.join(", ")
));
if !sorted.repo.is_empty() {
operations::install(sorted.repo, options);
}
@ -154,11 +162,13 @@ fn main() {
if let true = matches.is_present("remove") {
let packages = collect_matches(&matches);
info(format!("Uninstalling packages: {}", &packages.join(", ")));
operations::uninstall(packages, options);
exit(0);
}
if let true = matches.is_present("upgrade") {
info("Performing system upgrade".to_string());
operations::upgrade(options);
exit(0);
}
@ -170,6 +180,7 @@ fn main() {
.unwrap()
.is_present("aur")
{
info(format!("Searching AUR for {}", &packages[0]));
operations::aur_search(&packages[0], options);
}
if matches
@ -177,6 +188,7 @@ fn main() {
.unwrap()
.is_present("repo")
{
info(format!("Searching repos for {}", &packages[0]));
operations::search(&packages[0], options);
}
@ -189,6 +201,7 @@ fn main() {
.unwrap()
.is_present("aur")
{
info(format!("Searching AUR and repos for {}", &packages[0]));
operations::search(&packages[0], options);
operations::aur_search(&packages[0], options);
}

@ -1,10 +1,11 @@
use crate::internal::crash;
use crate::internal::rpc::rpcinfo;
use crate::Options;
use crate::{info, Options};
use std::env;
use std::env::set_current_dir;
use std::fs::remove_dir_all;
use std::path::Path;
use std::process::Command;
use std::process::{Command, Stdio};
pub fn aur_install(a: Vec<String>, options: Options) {
let url = crate::internal::rpc::URL;
@ -25,6 +26,8 @@ pub fn aur_install(a: Vec<String>, options: Options) {
}
}
info(format!("Installing packages {} from the AUR", a.join(", ")));
for package in a {
let rpcres = rpcinfo(package);
@ -38,11 +41,13 @@ pub fn aur_install(a: Vec<String>, options: Options) {
eprintln!("Cloning {} into cachedir", pkg);
}
// cloning
info("Cloning package source".to_string());
set_current_dir(Path::new(&cachedir)).unwrap();
Command::new("git")
.arg("clone")
.arg(format!("{}/{}", url, pkg))
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong");
@ -59,10 +64,11 @@ pub fn aur_install(a: Vec<String>, options: Options) {
}
// dep sorting
info("Sorting dependencies".to_string());
let sorted = crate::internal::sort(&rpcres.package.as_ref().unwrap().depends, options);
if verbosity >= 1 {
eprintln!("Sorted depndencies for {} are:\n{:?}", pkg, &sorted)
eprintln!("Sorted dependencies for {} are:\n{:?}", pkg, &sorted)
}
let newopts = Options {
@ -91,6 +97,7 @@ pub fn aur_install(a: Vec<String>, options: Options) {
}
// dep installing
info("Moving on to install dependencies".to_string());
crate::operations::install(sorted.repo, newopts);
crate::operations::aur_install(sorted.aur, newopts);
@ -103,12 +110,20 @@ pub fn aur_install(a: Vec<String>, options: Options) {
}
// package building and installing
info("Building time!".to_string());
set_current_dir(format!("{}/{}", cachedir, pkg)).unwrap();
Command::new("makepkg")
let out = Command::new("makepkg")
.args(&makepkg_args)
.status()
.expect("Something has gone wrong");
if out.code() != Some(0) {
crash(
format!("Error encountered while installing {}, aborting", pkg),
1,
);
}
if makepkg_args.contains(&"--asdeps") {
set_current_dir(&cachedir).unwrap();
remove_dir_all(format!("{}/{}", cachedir, pkg)).unwrap();

@ -1,6 +1,7 @@
use crate::Options;
use crate::{info, Options};
pub fn install(mut a: Vec<String>, options: Options) {
info(format!("Installing packages {} from repos", &a.join(", ")));
let b = a.clone();
if options.noconfirm {
a.push("--noconfirm".to_string());
@ -28,7 +29,7 @@ pub fn install(mut a: Vec<String>, options: Options) {
.arg("--needed")
.args(&a)
.status()
.expect("Something has gone wrong.");
.expect("Something has gone wrong");
if let Some(x) = r.code() {
if verbosity >= 1 {

@ -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);
}
Loading…
Cancel
Save