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

@ -52,7 +52,7 @@ fn uninstall_make_depend(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 pkgdir = format!("{}/{}", &cachedir, &pkg);
let package = raur::info(&[pkg]).unwrap();

@ -1,19 +1,18 @@
use crate::{err_unrec, inf};
use std::fs::File;
use std::io::{Error, Write};
use std::{fs, io::{Error, Write}, env, path};
use toml_edit::{value, Document};
use crate::mods::strs::{err_rec};
pub fn get_value(pkg: &str, sear_value: &str) -> String {
let homepath = std::env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap());
let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new();
match std::path::Path::new(&file).exists() {
match path::Path::new(&file).exists() {
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 => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath));
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar {
Ok(_) => {
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"));
let _dbfile = std::fs::File::create(&file);
let _dbfile = fs::File::create(&file);
match _dbfile {
Ok(_) => {
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>) {
let homepath = std::env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap());
let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new();
match std::path::Path::new(&file).exists() {
match path::Path::new(&file).exists() {
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 => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath));
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar {
Ok(_) => {
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"));
let _dbfile = std::fs::File::create(&file);
let _dbfile = fs::File::create(&file);
match _dbfile {
Ok(_) => {
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);
match db_update_res {
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> {
let homepath = std::env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", std::env::var("HOME").unwrap());
let homepath = env::var("HOME").unwrap();
let file = format!("{}/.local/ame/aurPkgs.db", env::var("HOME").unwrap());
let mut database = String::new();
match std::path::Path::new(&file).exists() {
match path::Path::new(&file).exists() {
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 => {
let _cdar = std::fs::create_dir_all(format!("/{}/.local/ame/",homepath));
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
match _cdar {
Ok(_) => {
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"));
let _dbfile = std::fs::File::create(&file);
let _dbfile = fs::File::create(&file);
match _dbfile {
Ok(_) => {
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 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 {
let results = raur::search(&pkg);
for res in &results {
//for r in res {
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]["name"] = value(&res[0].name);
db_parsed[&res[0].name]["version"] = value(&res[0].version);
}
} else {
db_parsed[&pkg]["name"] = value(pkg);

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

@ -1,8 +1,8 @@
use ansi_term::Colour;
use std::{env, io, io::Write, process};
use std::{env, io, io::Write, process, string};
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" {
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" {
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" {
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" {
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" {
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" {
println!(
"{} {}",

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

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

Loading…
Cancel
Save