4 Commits

Author SHA1 Message Date
7587815818 version and pkgbuild bump 2024-08-04 22:59:26 +02:00
085debe43c refactor and choose install 2024-08-04 22:53:15 +02:00
f2f3997469 readme update 2024-07-24 19:51:08 +02:00
d3d1b38f7e pkgbuild 2024-07-24 19:38:44 +02:00
15 changed files with 177 additions and 45 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
/target /target
*.tar.zst
/pkg

50
Cargo.lock generated
View File

@@ -4,7 +4,7 @@ version = 3
[[package]] [[package]]
name = "ah" name = "ah"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"clap", "clap",
"colored", "colored",
@@ -12,9 +12,9 @@ dependencies = [
[[package]] [[package]]
name = "anstream" name = "anstream"
version = "0.6.14" version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"anstyle-parse", "anstyle-parse",
@@ -27,33 +27,33 @@ dependencies = [
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]] [[package]]
name = "anstyle-parse" name = "anstyle-parse"
version = "0.2.4" version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [ dependencies = [
"utf8parse", "utf8parse",
] ]
[[package]] [[package]]
name = "anstyle-query" name = "anstyle-query"
version = "1.1.0" version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
name = "anstyle-wincon" name = "anstyle-wincon"
version = "3.0.3" version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@@ -61,9 +61,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.10" version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@@ -71,9 +71,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.10" version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@@ -83,9 +83,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.5.8" version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@@ -95,15 +95,15 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]] [[package]]
name = "colored" name = "colored"
@@ -123,9 +123,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.0" version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
@@ -159,9 +159,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.71" version = "2.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -1,8 +1,17 @@
[package] [package]
name = "ah" name = "ah"
version = "0.1.0" version = "0.2.0"
authors = ["Michał Czyż <mike@c2yz.com>"]
edition = "2021" edition = "2021"
description = "A declarative package manager for Arch Linux"
homepage = "https://github.com/eRgo35/ah"
repository = "https://github.com/eRgo35/ah"
documentation = "https://github.com/eRgo35/ah"
license = "MIT"
keywords = ["archlinux", "declarative", "package", "aur", "paru"]
readme = "README.md"
[dependencies] [dependencies]
clap = { version = "4.5.10", features = ["derive"] } clap = { version = "4.5.10", features = ["derive"] }
colored = "2.1.0" colored = "2.1.0"

18
PKGBUILD Normal file
View File

@@ -0,0 +1,18 @@
# Maintainer: Michał Czyż <mike@c2yz.com>
pkgname=ah
pkgver=0.2.0
pkgrel=1
makedepends=('rust' 'cargo')
arch=('i686' 'x86_64' 'armv6h' 'armv7h')
pkgdesc="A declarative package manager for Arch Linux"
url="https://github.com/eRgo35/ah"
license=('MIT')
build() {
return 0
}
package() {
cd $srcdir
cargo install --root="$pkgdir" --git=https://github.com/eRgo35/ah
}

View File

@@ -1,9 +1,63 @@
# ah # ah
Yet another AUR helper A declarative package manager for Arch Linux
## What is ah? ## What is ah?
AH is a wrapper for paru that allows for declarative management of packages on your system. Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration.
It is currently in early development phase so watch out for bugs! It is currently in early development phase so watch out for bugs!
## Installation
Install Rust :crab:
```sh
$ sudo pacman -S rustup
```
Initialize default stable
```sh
$ rustup default stable
```
Clone this repo
```sh
$ git clone https://github.com/eRgo35/ah
```
Change directory
```sh
$ cd ah
```
Install package
```sh
$ makepkg -si
```
## Usage
```txt
$ ah --help
Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration.
Usage: ah [COMMAND]
Commands:
install Install packages
upgrade Upgrade packages
sync Synchronize packages
remove Remove packages
find Find packages
help Print this message or the help of the given subcommand(s)
Options:
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
```

View File

@@ -35,6 +35,9 @@ pub enum Commands {
#[command(alias = "f", about = "Find packages")] #[command(alias = "f", about = "Find packages")]
Find(Query), Find(Query),
#[command(alias = "fi", about = "Find and install packages")]
ChooseInstall(Query),
} }
#[derive(Args)] #[derive(Args)]

View File

@@ -15,7 +15,8 @@ fn main() {
Some(cli::Commands::Sync { noconfirm }) => packages::sync(noconfirm), Some(cli::Commands::Sync { noconfirm }) => packages::sync(noconfirm),
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages), Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
Some(cli::Commands::Find(Query { query })) => packages::find(query), Some(cli::Commands::Find(Query { query })) => packages::find(query),
None => packages::rebuild(true), Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
None => packages::upgrade(true),
}; };
if let Err(err) = result { if let Err(err) = result {

View File

@@ -0,0 +1,50 @@
use colored::Colorize;
use std::io::Write;
use std::process::{Command, Stdio};
use crate::packages::PACKAGE_MANAGER;
pub fn choose_install(query: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {
println!(
"{} {}",
"::".bold().green(),
"Looking for package...".bold()
);
if query.is_empty() {
return Err("No query provided".into());
}
let mut child = Command::new(PACKAGE_MANAGER)
.arg("--color")
.arg("always")
.arg("s")
.arg("-")
.stdin(Stdio::piped())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.expect("Failed to execute command");
if let Some(mut stdin) = child.stdin.take() {
for word in query.clone() {
writeln!(stdin, "{}", word).unwrap();
}
}
let status = child.wait().expect("Failed to wait on child");
if !status.success() {
return Err("Failed to install packages".into());
}
println!("{} {}", "::".bold().green(), "Packages installed".bold());
println!(
"{} {}",
"::".bold().red(),
"Package index has not been updated!".bold()
);
Ok(())
}

View File

@@ -1,7 +1,7 @@
use colored::Colorize; use colored::Colorize;
use std::process::Command; use std::process::Command;
const PACKAGE_MANAGER: &str = "paru"; use crate::packages::PACKAGE_MANAGER;
pub fn find(query: Vec<String>) -> Result<(), Box<dyn std::error::Error>> { pub fn find(query: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {
println!( println!(

View File

@@ -1,10 +1,9 @@
use crate::packages::PACKAGE_MANAGER;
use crate::{file, packages::get_package_path}; use crate::{file, packages::get_package_path};
use colored::Colorize; use colored::Colorize;
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
const PACKAGE_MANAGER: &str = "paru";
pub fn install(new_packages: Vec<String>) -> Result<(), Box<dyn std::error::Error>> { pub fn install(new_packages: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {
println!( println!(
"{} {}", "{} {}",
@@ -24,7 +23,6 @@ pub fn install(new_packages: Vec<String>) -> Result<(), Box<dyn std::error::Erro
.arg("always") .arg("always")
.arg("-S") .arg("-S")
.arg("--needed") .arg("--needed")
// .arg(noconfirm)
.arg("-") .arg("-")
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::inherit()) .stdout(Stdio::inherit())

View File

@@ -2,6 +2,7 @@ use colored::Colorize;
use std::io::{self, Write}; use std::io::{self, Write};
use std::path::PathBuf; use std::path::PathBuf;
pub mod choose_install;
pub mod find; pub mod find;
pub mod install; pub mod install;
pub mod rebuild; pub mod rebuild;
@@ -9,6 +10,7 @@ pub mod remove;
pub mod sync; pub mod sync;
pub mod upgrade; pub mod upgrade;
pub use choose_install::choose_install;
pub use find::find; pub use find::find;
pub use install::install; pub use install::install;
pub use rebuild::rebuild; pub use rebuild::rebuild;
@@ -16,6 +18,8 @@ pub use remove::remove;
pub use sync::sync; pub use sync::sync;
pub use upgrade::upgrade; pub use upgrade::upgrade;
const PACKAGE_MANAGER: &str = "paru";
fn get_package_path() -> PathBuf { fn get_package_path() -> PathBuf {
let home_dir = std::env::var("HOME").unwrap(); let home_dir = std::env::var("HOME").unwrap();

View File

@@ -3,9 +3,7 @@ use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use crate::file; use crate::file;
use crate::packages::{ask_confirmation, get_package_path}; use crate::packages::{ask_confirmation, get_package_path, PACKAGE_MANAGER};
const PACKAGE_MANAGER: &str = "paru";
pub fn rebuild(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> { pub fn rebuild(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
println!( println!(

View File

@@ -1,10 +1,9 @@
use crate::packages::PACKAGE_MANAGER;
use crate::{file, packages::get_package_path}; use crate::{file, packages::get_package_path};
use colored::Colorize; use colored::Colorize;
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
const PACKAGE_MANAGER: &str = "paru";
pub fn remove(unwanted_packages: Vec<String>) -> Result<(), Box<dyn std::error::Error>> { pub fn remove(unwanted_packages: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {
println!("{} {}", "::".bold().green(), "Removing packages...".bold()); println!("{} {}", "::".bold().green(), "Removing packages...".bold());

View File

@@ -3,9 +3,7 @@ use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use crate::file; use crate::file;
use crate::packages::{ask_confirmation, get_package_path}; use crate::packages::{ask_confirmation, get_package_path, PACKAGE_MANAGER};
const PACKAGE_MANAGER: &str = "paru";
pub fn sync(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> { pub fn sync(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
println!("{} {}", "::".bold().green(), "Syncing packages...".bold()); println!("{} {}", "::".bold().green(), "Syncing packages...".bold());

View File

@@ -1,9 +1,7 @@
use colored::Colorize; use colored::Colorize;
use std::process::Command; use std::process::Command;
use crate::packages::ask_confirmation; use crate::packages::{ask_confirmation, PACKAGE_MANAGER};
const PACKAGE_MANAGER: &str = "paru";
pub fn upgrade(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> { pub fn upgrade(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
println!("{} {}", "::".bold().green(), "Upgrading packages...".bold()); println!("{} {}", "::".bold().green(), "Upgrading packages...".bold());