diff --git a/Cargo.toml b/Cargo.toml index 1678aaf..0d21729 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "Amethyst" version = "3.0.0" -authors = [ "michal ", "axtlos " ] +authors = ["michal ", "axtlos "] 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" \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index d8f1f21..ba4c143 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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. diff --git a/README.md b/README.md index 21cecc4..de983e0 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Made for Crystal, compatible with any Arch-based Linux distribution.

![](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.

| 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`

diff --git a/src/database/add.rs b/src/database/add.rs index 8b1497d..b6fea36 100644 --- a/src/database/add.rs +++ b/src/database/add.rs @@ -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 diff --git a/src/database/initialise.rs b/src/database/initialise.rs index 8eac1b2..d4f0610 100644 --- a/src/database/initialise.rs +++ b/src/database/initialise.rs @@ -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); diff --git a/src/database/query.rs b/src/database/query.rs index a9289df..89e3016 100644 --- a/src/database/query.rs +++ b/src/database/query.rs @@ -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 { let verbosity = options.verbosity; diff --git a/src/database/remove.rs b/src/database/remove.rs index bb7a5ab..c213e3b 100644 --- a/src/database/remove.rs +++ b/src/database/remove.rs @@ -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", diff --git a/src/internal/clean.rs b/src/internal/clean.rs index ee20893..f6fbcc5 100644 --- a/src/internal/clean.rs +++ b/src/internal/clean.rs @@ -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 { let r = Regex::new(r"(\S+)((?:>=|<=|>|<)\S+$)").unwrap(); diff --git a/src/internal/initialise.rs b/src/internal/initialise.rs index 5e8b071..bf5b004 100644 --- a/src/internal/initialise.rs +++ b/src/internal/initialise.rs @@ -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(); diff --git a/src/internal/sort.rs b/src/internal/sort.rs index 977d5cd..64d6430 100644 --- a/src/internal/sort.rs +++ b/src/internal/sort.rs @@ -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 = vec![]; diff --git a/src/main.rs b/src/main.rs index 1999d6b..a724c27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index a5f7b72..ad97ae4 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -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, options: Options) { let url = crate::internal::rpc::URL; let cachedir = format!("{}/.cache/ame/", env::var("HOME").unwrap()); diff --git a/src/operations/search.rs b/src/operations/search.rs index 90027f2..08d5006 100644 --- a/src/operations/search.rs +++ b/src/operations/search.rs @@ -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; diff --git a/src/operations/uninstall.rs b/src/operations/uninstall.rs index 888109f..0e2ef05 100644 --- a/src/operations/uninstall.rs +++ b/src/operations/uninstall.rs @@ -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, options: Options) { let b = a.clone(); if options.noconfirm { diff --git a/src/operations/upgrade.rs b/src/operations/upgrade.rs index b86e906..7cbea10 100644 --- a/src/operations/upgrade.rs +++ b/src/operations/upgrade.rs @@ -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;