make the version in ame -V synced to the version in cargo.toml

i18n
amy 3 years ago
parent e72389baf1
commit 773e3c9cca

@ -1,6 +1,6 @@
[package] [package]
name = "ame" name = "ame"
version = "2.4.1" version = "2.4.2"
authors = [ "jnats <jnats@salyut.one>", "axtlos <axtlos@salyut.one>" ] authors = [ "jnats <jnats@salyut.one>", "axtlos <axtlos@salyut.one>" ]
edition = "2018" edition = "2018"
description = "a fast and efficient aur helper." description = "a fast and efficient aur helper."
@ -18,4 +18,5 @@ regex = "*"
toml_edit = "0.5.0" toml_edit = "0.5.0"
toml = "*" toml = "*"
bytes = "*" bytes = "*"
nix = "*" nix = "*"
clap = "*"

@ -52,7 +52,7 @@ fn uninstall_make_depend(pkg: &str) {
} }
pub fn clone(noconfirm: bool, as_dep: bool, pkg: &str) { pub fn clone(noconfirm: bool, as_dep: bool, pkg: &str) {
let cachedir = format!("{}/.cache/ame", std::env::var("HOME").unwrap()); let cachedir = format!("{}/.cache/ame", env::var("HOME").unwrap());
let path = Path::new(&cachedir); let path = Path::new(&cachedir);
let pkgdir = format!("{}/{}", &cachedir, &pkg); let pkgdir = format!("{}/{}", &cachedir, &pkg);
let package = raur::info(&[pkg]).unwrap(); let package = raur::info(&[pkg]).unwrap();

@ -1,19 +1,18 @@
use crate::{err_unrec, inf}; use crate::{err_unrec, inf};
use std::fs::File; use std::{fs, io::{Error, Write}, env, path};
use std::io::{Error, Write};
use toml_edit::{value, Document}; use toml_edit::{value, Document};
use crate::mods::strs::{err_rec}; use crate::mods::strs::{err_rec};
pub fn get_value(pkg: &str, sear_value: &str) -> String { pub fn get_value(pkg: &str, sear_value: &str) -> String {
let homepath = std::env::var("HOME").unwrap(); let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap()); let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new(); let mut database = String::new();
match std::path::Path::new(&file).exists() { match path::Path::new(&file).exists() {
true => { true => {
database = std::fs::read_to_string(&file).expect("Can't Open Database"); database = fs::read_to_string(&file).expect("Can't Open Database");
} }
false => { false => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath)); let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar { match _cdar {
Ok(_) => { Ok(_) => {
inf(format!("Created path for database (previously missing)")) inf(format!("Created path for database (previously missing)"))
@ -23,7 +22,7 @@ pub fn get_value(pkg: &str, sear_value: &str) -> String {
} }
} }
err_rec(String::from("Datbase wasn't found, creating new one")); err_rec(String::from("Datbase wasn't found, creating new one"));
let _dbfile = std::fs::File::create(&file); let _dbfile = fs::File::create(&file);
match _dbfile { match _dbfile {
Ok(_) => { Ok(_) => {
inf(format!("Created empty database (previously missing)")) inf(format!("Created empty database (previously missing)"))
@ -73,15 +72,15 @@ pub fn get_value(pkg: &str, sear_value: &str) -> String {
} }
pub fn rem_pkg(pkgs: &Vec<String>) { pub fn rem_pkg(pkgs: &Vec<String>) {
let homepath = std::env::var("HOME").unwrap(); let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap()); let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new(); let mut database = String::new();
match std::path::Path::new(&file).exists() { match path::Path::new(&file).exists() {
true => { true => {
database = std::fs::read_to_string(&file).expect("Can't Open Database"); database = fs::read_to_string(&file).expect("Can't Open Database");
} }
false => { false => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath)); let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar { match _cdar {
Ok(_) => { Ok(_) => {
inf(format!("Created path for database (previously missing)")) inf(format!("Created path for database (previously missing)"))
@ -91,7 +90,7 @@ pub fn rem_pkg(pkgs: &Vec<String>) {
} }
} }
err_rec(String::from("Datbase wasn't found, creating new one")); err_rec(String::from("Datbase wasn't found, creating new one"));
let _dbfile = std::fs::File::create(&file); let _dbfile = fs::File::create(&file);
match _dbfile { match _dbfile {
Ok(_) => { Ok(_) => {
inf(format!("Created empty database (previously missing)")) inf(format!("Created empty database (previously missing)"))
@ -116,7 +115,7 @@ pub fn rem_pkg(pkgs: &Vec<String>) {
} }
} }
} }
let file_as_path = File::create(std::path::Path::new(&file)).unwrap(); let file_as_path = fs::File::create(path::Path::new(&file)).unwrap();
let db_update_res = write!(&file_as_path, "{}", update_database); let db_update_res = write!(&file_as_path, "{}", update_database);
match db_update_res { match db_update_res {
Ok(_) => inf(format!("Database update successful")), Ok(_) => inf(format!("Database update successful")),
@ -125,15 +124,15 @@ pub fn rem_pkg(pkgs: &Vec<String>) {
} }
pub fn add_pkg(from_repo: bool, pkg: &str) -> Result<(), Error> { pub fn add_pkg(from_repo: bool, pkg: &str) -> Result<(), Error> {
let homepath = std::env::var("HOME").unwrap(); let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap()); let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new(); let mut database = String::new();
match std::path::Path::new(&file).exists() { match path::Path::new(&file).exists() {
true => { true => {
database = std::fs::read_to_string(&file).expect("Can't Open Database"); database = fs::read_to_string(&file).expect("Can't Open Database");
} }
false => { false => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath)); let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar { match _cdar {
Ok(_) => { Ok(_) => {
inf(format!("Created path for database (previously missing)")) inf(format!("Created path for database (previously missing)"))
@ -143,7 +142,7 @@ pub fn add_pkg(from_repo: bool, pkg: &str) -> Result<(), Error> {
} }
} }
err_rec(String::from("Datbase wasn't found, creating new one")); err_rec(String::from("Datbase wasn't found, creating new one"));
let _dbfile = std::fs::File::create(&file); let _dbfile = fs::File::create(&file);
match _dbfile { match _dbfile {
Ok(_) => { Ok(_) => {
inf(format!("Created empty database (previously missing)")) inf(format!("Created empty database (previously missing)"))
@ -155,14 +154,12 @@ pub fn add_pkg(from_repo: bool, pkg: &str) -> Result<(), Error> {
} }
} }
let mut db_parsed = database.parse::<Document>().expect("Invalid Database"); let mut db_parsed = database.parse::<Document>().expect("Invalid Database");
let mut file_as_path = File::create(std::path::Path::new(&file))?; let mut file_as_path = fs::File::create(path::Path::new(&file))?;
if from_repo == false { if from_repo == false {
let results = raur::search(&pkg); let results = raur::search(&pkg);
for res in &results { for res in &results {
//for r in res { db_parsed[&res[0].name]["name"] = value(&res[0].name);
db_parsed[&res[0].name]["name"] = value(&res[0].name); db_parsed[&res[0].name]["version"] = value(&res[0].version);
db_parsed[&res[0].name]["version"] = value(&res[0].version);
//}
} }
} else { } else {
db_parsed[&pkg]["name"] = value(pkg); db_parsed[&pkg]["name"] = value(pkg);

@ -1,11 +1,12 @@
use crate::{clone, err_unrec, install, mods::strs::sec}; use crate::{clone, err_unrec, install, mods::strs::sec};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use regex::Regex;
pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) { pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) {
let mut repo = vec![]; let mut repo = vec![];
let mut aur = vec![]; let mut aur = vec![];
let re = regex::Regex::new(r"(\S+)((?:>=|<=)\S+$)").unwrap(); let re = Regex::new(r"(\S+)((?:>=|<=)\S+$)").unwrap();
let reg = regex::Regex::new(r"((?:>=|<=)\S+$)").unwrap(); let reg = Regex::new(r"((?:>=|<=)\S+$)").unwrap();
for pkg in pkgs { for pkg in pkgs {
let caps = re.captures(&pkg); let caps = re.captures(&pkg);
match caps { match caps {

@ -1,8 +1,8 @@
use ansi_term::Colour; use ansi_term::Colour;
use std::{env, io, io::Write, process}; use std::{env, io, io::Write, process, string};
use uwuizer::*; use uwuizer::*;
pub fn inf(a: std::string::String) { pub fn inf(a: string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!( println!(
"{} {}", "{} {}",
@ -14,7 +14,7 @@ pub fn inf(a: std::string::String) {
} }
} }
pub fn sec(a: std::string::String) { pub fn sec(a: string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!( println!(
"{} {}", "{} {}",
@ -30,7 +30,7 @@ pub fn sec(a: std::string::String) {
} }
} }
pub fn succ(a: std::string::String) { pub fn succ(a: string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!( println!(
"{} {}", "{} {}",
@ -46,7 +46,7 @@ pub fn succ(a: std::string::String) {
} }
} }
pub fn prompt(a: std::string::String) -> bool { pub fn prompt(a: string::String) -> bool {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
print!( print!(
"{} {} {}", "{} {} {}",
@ -80,7 +80,7 @@ pub fn prompt(a: std::string::String) -> bool {
} }
} }
pub fn err_unrec(a: std::string::String) { pub fn err_unrec(a: string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!( println!(
"{} {} {}", "{} {} {}",
@ -100,7 +100,7 @@ pub fn err_unrec(a: std::string::String) {
} }
} }
pub fn err_rec(a: std::string::String) { pub fn err_rec(a: string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!( println!(
"{} {}", "{} {}",

@ -24,13 +24,13 @@ fn uninstall_make_depend(pkg: &str) {
} }
pub fn upgrade(noconfirm: bool) { pub fn upgrade(noconfirm: bool) {
let homepath = std::env::var("HOME").unwrap(); let homepath = env::var("HOME").unwrap();
let cachedir = format!("/{}/.cache/ame/", homepath); let cachedir = format!("/{}/.cache/ame/", homepath);
let cache_exists = std::path::Path::new(&format!("/{}/.cache/ame/", homepath)).is_dir(); let cache_exists = Path::new(&format!("/{}/.cache/ame/", homepath)).is_dir();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap()); let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let database = String::new(); let database = String::new();
if std::path::Path::new(&file).exists() { if Path::new(&file).exists() {
let _db = std::fs::read_to_string(&file).expect("Can't Open Database"); let _db = fs::read_to_string(&file).expect("Can't Open Database");
} else { } else {
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/", homepath)); let _cdar = fs::create_dir_all(format!("/{}/.local/ame/", homepath));
match _cdar { match _cdar {
@ -42,7 +42,7 @@ pub fn upgrade(noconfirm: bool) {
} }
} }
err_rec(String::from("Database wasn't found, creating new one")); err_rec(String::from("Database wasn't found, creating new one"));
let _dbfile = std::fs::File::create(&file); let _dbfile = fs::File::create(&file);
let _db = String::new(); let _db = String::new();
} }
let db_parsed = database.parse::<toml::Value>().expect("Invalid Database"); let db_parsed = database.parse::<toml::Value>().expect("Invalid Database");
@ -87,7 +87,7 @@ pub fn upgrade(noconfirm: bool) {
let version = get_value(&key, "version"); let version = get_value(&key, "version");
if res[0].version.contains(&version) { if res[0].version.contains(&version) {
let keydir = format!("{}{}", &cachedir, &key); let keydir = format!("{}{}", &cachedir, &key);
if std::path::Path::new(&keydir).is_dir() { if Path::new(&keydir).is_dir() {
let cd_result = env::set_current_dir(&keydir); let cd_result = env::set_current_dir(&keydir);
match cd_result { match cd_result {
Ok(_) => inf(format!("Entered package directory")), Ok(_) => inf(format!("Entered package directory")),

@ -1,9 +1,10 @@
use crate::inf; use crate::inf;
use ansi_term::Colour; use ansi_term::Colour;
use clap::{self, crate_version};
pub fn ver() { pub fn ver() {
println!(""); println!("");
inf(format!("ame - v2.4.1")); inf(format!("ame - {}",crate_version!()));
println!(""); println!("");
inf(format!("Contributors:")); inf(format!("Contributors:"));
println!("- axtlos <axtlos@salyut.one>"); println!("- axtlos <axtlos@salyut.one>");

Loading…
Cancel
Save