general code cleanup

i18n
michal 2 years ago
parent 6475eacbba
commit 59b443c607

@ -1,7 +1,7 @@
[package]
name = "Amethyst"
version = "3.0.0"
authors = [ "michal <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."
license-file = "LICENSE.md"
@ -12,32 +12,32 @@ pkg-warner = []
[[bin]]
name = "apt"
path = "src/bin/apt.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "apt-get"
path = "src/bin/apt-get.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "dnf"
path = "src/bin/dnf.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "eopkg"
path = "src/bin/eopkg.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "yum"
path = "src/bin/yum.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "zypper"
path = "src/bin/zypper.rs"
required-features = [ "pkg-warner" ]
required-features = ["pkg-warner"]
[[bin]]
name = "ame"
@ -51,10 +51,10 @@ codegen-units = 1
[dependencies]
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" ] }
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 }
ureq = { version = "2.4.0", default-features = false, features = [ "native-tls", "json" ] }
serde = { version = "1.0.90", default-features = false, features = [ "derive", "serde_derive" ] }
ureq = { version = "2.4.0", default-features = false, features = ["native-tls", "json"] }
serde = { version = "1.0.90", default-features = false, features = ["derive", "serde_derive"] }
native-tls = "0.2.8"

@ -1,18 +1,23 @@
The Nolicense
Revision 2.1 - Monday 15th November 2021
The Nolicense Revision 2.1 - Monday 15th November 2021
Copyright (c) 2022 Crystal Linux Team
Everyone is permitted to freely copy and distribute this license document.
Modified redistributions are subject to the following license agreement.
Everyone is permitted to freely copy and distribute this license document. Modified redistributions are subject to the
following license agreement.
The Nolicense terms and conditions for copying, distribution and modification of software and any created assets are as follows:
The Nolicense terms and conditions for copying, distribution and modification of software and any created assets are as
follows:
- Any unmodified redistributions in either source code or binary form must retain this copyright notice in its entirety.
- Any and all redistributions or derivative works, whether modified or unmodified, must credit the original author(s) of the source code, and provide an easily accessible way to find the original author's source code, wherever it may be published.
- Any and all redistributions or derivative works, whether modified or unmodified, must credit the original author(s) of
the source code, and provide an easily accessible way to find the original author's source code, wherever it may be
published.
- Derivative works and modified redistributions cannot be published under the same name as the original software, nor can it be presented as an extension of or newer revision of said software, and unless explicitly permitted, the original authors name(s) shall not be used to endorse said derivative works.
- Derivative works and modified redistributions cannot be published under the same name as the original software, nor
can it be presented as an extension of or newer revision of said software, and unless explicitly permitted, the
original authors name(s) shall not be used to endorse said derivative works.
This software is provided as-is; Neither the copyright holders nor any contributors to the software are to be held liable for any damages caused by any files attached.
By modifying or redistributing the software in any way, you automatically agree to the terms of the license agreement.
This software is provided as-is; Neither the copyright holders nor any contributors to the software are to be held
liable for any damages caused by any files attached. By modifying or redistributing the software in any way, you
automatically agree to the terms of the license agreement.

@ -15,6 +15,7 @@ Made for Crystal, compatible with any Arch-based Linux distribution.</p>
![](screenshot.png)
## Basic usage
| Action | FreeBSD pkg-style alias | Pacman-style flag(s) |
|----------------------|-------------------------|----------------------|
| Install a package | ame ins/install | ame -S |
@ -22,18 +23,21 @@ Made for Crystal, compatible with any Arch-based Linux distribution.</p>
| Upgrade a package | ame upg/upgrade | ame -Syu |
| Search for a package | ame sea | ame -Ss |
## How to build:
(Install cargo)
For release:
- `make clean release`
- `make clean release`
For general debug/test:
- `make debug`
- `make debug`
Clean all build directories:
- `make clean`
- `make clean`
<br>
<br>

@ -1,9 +1,11 @@
use crate::internal::rpc::Package;
use crate::{crash, log, Options};
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::internal::rpc::Package;
use crate::{crash, log, Options};
pub fn add(pkg: Package, options: Options) {
let conn = Connection::open(Path::new(&format!(
"{}/.local/share/ame/db.sqlite",
@ -15,8 +17,8 @@ pub fn add(pkg: Package, options: Options) {
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)",
[&pkg.name, &pkg.version, &pkg.description.unwrap_or_else(|| "No description found.".parse().unwrap()), &pkg.depends.join(" "), &pkg.make_depends.join(" ")]
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(" ")],
).unwrap_or_else(|e| {
crash(format!("Failed adding package {} to the database: {}", pkg.name, e), 1);
1

@ -1,8 +1,10 @@
use crate::{crash, log, Options};
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::{crash, log, Options};
pub fn init(options: Options) {
let path = format!("{}/.local/share/ame/db.sqlite", env::var("HOME").unwrap());
let dbpath = Path::new(&path);

@ -1,9 +1,11 @@
use crate::internal::rpc::Package;
use crate::{log, Options};
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::internal::rpc::Package;
use crate::{log, Options};
pub fn query(a: &str, options: Options) -> Vec<Package> {
let verbosity = options.verbosity;

@ -1,8 +1,10 @@
use crate::{log, Options};
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::{log, Options};
pub fn remove(pkg: &str, options: Options) {
let conn = Connection::open(Path::new(&format!(
"{}/.local/share/ame/db.sqlite",

@ -1,6 +1,7 @@
use regex::Regex;
use crate::internal::strings::log;
use crate::Options;
use regex::Regex;
pub fn clean(a: &[String], options: Options) -> Vec<String> {
let r = Regex::new(r"(\S+)((?:>=|<=|>|<)\S+$)").unwrap();

@ -1,8 +1,9 @@
use crate::internal::strings::{crash, log};
use crate::Options;
use std::env;
use std::path::Path;
use crate::internal::strings::{crash, log};
use crate::Options;
pub fn init(options: Options) {
let verbosity = options.verbosity;
let homedir = env::var("HOME").unwrap();

@ -1,7 +1,8 @@
use std::process::{Command, Stdio};
use crate::internal::strings::log;
use crate::internal::{clean, rpc, structs};
use crate::Options;
use std::process::{Command, Stdio};
pub fn sort(input: &[String], options: Options) -> structs::Sorted {
let mut repo: Vec<String> = vec![];

@ -1,3 +1,10 @@
use std::io;
use std::process::exit;
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand};
use crate::internal::{crash, info, init, log, sort, structs::Options};
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -5,11 +12,6 @@ mod database;
mod internal;
mod operations;
use crate::internal::{crash, info, init, log, sort, structs::Options};
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand};
use std::io;
use std::process::exit;
fn main() {
extern "C" {
fn geteuid() -> u32;

@ -1,12 +1,13 @@
use crate::internal::crash;
use crate::internal::rpc::rpcinfo;
use crate::{info, log, Options};
use std::env;
use std::env::set_current_dir;
use std::fs::remove_dir_all;
use std::path::Path;
use std::process::{Command, Stdio};
use crate::internal::crash;
use crate::internal::rpc::rpcinfo;
use crate::{info, log, Options};
pub fn aur_install(a: Vec<String>, options: Options) {
let url = crate::internal::rpc::URL;
let cachedir = format!("{}/.cache/ame/", env::var("HOME").unwrap());

@ -1,6 +1,7 @@
use std::process::Command;
use crate::internal::rpc::rpcsearch;
use crate::{log, Options};
use std::process::Command;
pub fn aur_search(a: &str, options: Options) {
let verbosity = options.verbosity;

@ -1,7 +1,8 @@
use crate::{log, Options};
use std::path::Path;
use std::{env, fs};
use crate::{log, Options};
pub fn uninstall(mut a: Vec<String>, options: Options) {
let b = a.clone();
if options.noconfirm {

@ -1,7 +1,8 @@
use runas::Command;
use crate::internal::rpc::rpcinfo;
use crate::operations::aur_install::aur_install;
use crate::{log, Options};
use runas::Command;
pub fn upgrade(options: Options) {
let verbosity = options.verbosity;

Loading…
Cancel
Save