Compare commits

6 Commits

Author SHA1 Message Date
7268726e82 automatic version bump 2024-08-04 23:50:53 +02:00
441a2a2367 cargo aur for package preparation 2024-08-04 23:10:21 +02:00
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 193 additions and 46 deletions

2
.gitignore vendored
View File

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

50
Cargo.lock generated
View File

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

View File

@@ -1,8 +1,17 @@
[package]
name = "ah"
version = "0.1.0"
version = "0.2.0"
authors = ["Michał Czyż <mike@c2yz.com>"]
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"
keywords = ["archlinux", "declarative", "package", "aur", "paru"]
license = "MIT"
readme = "README.md"
[dependencies]
clap = { version = "4.5.10", features = ["derive"] }
colored = "2.1.0"
colored = "2.1.0"

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Michał Czyż
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,9 +1,73 @@
# ah
Yet another AUR helper
A declarative package manager for Arch Linux
## 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!
## 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
```
```sh
$ cargo aur
```
```sh
$ cd target/cargo-aur
```
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

@@ -1,10 +1,12 @@
use clap::{Args, Parser, Subcommand};
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
#[derive(Parser)]
#[command(
name = "ah",
author = "Michał Czyż",
version = "0.1.0",
version = VERSION.unwrap_or("unknown"),
about = "A declarative package manager for Arch Linux",
long_about = "Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration."
)]
@@ -35,6 +37,9 @@ pub enum Commands {
#[command(alias = "f", about = "Find packages")]
Find(Query),
#[command(alias = "fi", about = "Find and install packages")]
ChooseInstall(Query),
}
#[derive(Args)]

View File

@@ -15,7 +15,8 @@ fn main() {
Some(cli::Commands::Sync { noconfirm }) => packages::sync(noconfirm),
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
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 {

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 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>> {
println!(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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