mirror of
https://github.com/eRgo35/ah.git
synced 2026-02-04 21:26:11 +01:00
Compare commits
3 Commits
v0.2.0
...
0d0cd4380c
| Author | SHA1 | Date | |
|---|---|---|---|
|
0d0cd4380c
|
|||
|
7268726e82
|
|||
|
441a2a2367
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4,7 +4,7 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ah"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ah"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
authors = ["Michał Czyż <mike@c2yz.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -8,8 +8,8 @@ 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"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
|
||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal 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.
|
||||
18
PKGBUILD
18
PKGBUILD
@@ -1,18 +0,0 @@
|
||||
# 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
|
||||
}
|
||||
12
README.md
12
README.md
@@ -23,15 +23,25 @@ $ rustup default stable
|
||||
```
|
||||
|
||||
Clone this repo
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/eRgo35/ah
|
||||
$ git clone https://github.com/eRgo35/ah
|
||||
```
|
||||
|
||||
Change directory
|
||||
|
||||
```sh
|
||||
$ cd ah
|
||||
```
|
||||
|
||||
```sh
|
||||
$ cargo aur
|
||||
```
|
||||
|
||||
```sh
|
||||
$ cd target/cargo-aur
|
||||
```
|
||||
|
||||
Install package
|
||||
|
||||
```sh
|
||||
|
||||
@@ -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."
|
||||
)]
|
||||
|
||||
@@ -23,7 +23,6 @@ pub fn read_packages(path: PathBuf) -> Vec<String> {
|
||||
|
||||
pub fn append_package(path: PathBuf, package: &str) {
|
||||
let mut file = OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
.open(path)
|
||||
.expect("Failed to open file");
|
||||
|
||||
@@ -16,7 +16,7 @@ fn main() {
|
||||
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
|
||||
Some(cli::Commands::Find(Query { query })) => packages::find(query),
|
||||
Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
|
||||
None => packages::upgrade(true),
|
||||
None => packages::full_upgrade(true),
|
||||
};
|
||||
|
||||
if let Err(err) = result {
|
||||
|
||||
32
src/packages/full_upgrade.rs
Normal file
32
src/packages/full_upgrade.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use colored::Colorize;
|
||||
use std::process::Command;
|
||||
|
||||
use crate::packages::{ask_confirmation, SYSTEM_UPDATER};
|
||||
|
||||
pub fn full_upgrade(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!(
|
||||
"{} {}",
|
||||
"::".bold().green(),
|
||||
"Initializing full system update...".bold()
|
||||
);
|
||||
|
||||
if !ask_confirmation()? {
|
||||
return Err("Operation aborted".into());
|
||||
}
|
||||
|
||||
let noconfirm = if noconfirm { "-y" } else { "" };
|
||||
|
||||
let mut child = Command::new(SYSTEM_UPDATER)
|
||||
.arg(noconfirm)
|
||||
.spawn()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
let status = child.wait().expect("Failed to wait on child");
|
||||
|
||||
if !status.success() {
|
||||
return Err("System upgrade failed".into());
|
||||
}
|
||||
|
||||
println!("{} {}", "::".bold().green(), "System upgraded".bold());
|
||||
Ok(())
|
||||
}
|
||||
@@ -4,6 +4,7 @@ use std::path::PathBuf;
|
||||
|
||||
pub mod choose_install;
|
||||
pub mod find;
|
||||
pub mod full_upgrade;
|
||||
pub mod install;
|
||||
pub mod rebuild;
|
||||
pub mod remove;
|
||||
@@ -12,12 +13,14 @@ pub mod upgrade;
|
||||
|
||||
pub use choose_install::choose_install;
|
||||
pub use find::find;
|
||||
pub use full_upgrade::full_upgrade;
|
||||
pub use install::install;
|
||||
pub use rebuild::rebuild;
|
||||
pub use remove::remove;
|
||||
pub use sync::sync;
|
||||
pub use upgrade::upgrade;
|
||||
|
||||
const SYSTEM_UPDATER: &str = "topgrade";
|
||||
const PACKAGE_MANAGER: &str = "paru";
|
||||
|
||||
fn get_package_path() -> PathBuf {
|
||||
@@ -27,11 +30,7 @@ fn get_package_path() -> PathBuf {
|
||||
}
|
||||
|
||||
fn ask_confirmation() -> Result<bool, io::Error> {
|
||||
print!(
|
||||
"{} {}",
|
||||
"::".bold().blue(),
|
||||
"Do you want to continue? [Y/n] "
|
||||
);
|
||||
print!("{} Do you want to continue? [Y/n] ", "::".bold().blue());
|
||||
io::stdout().flush()?;
|
||||
|
||||
let mut input = String::new();
|
||||
|
||||
Reference in New Issue
Block a user