From b91cafc50e2366beea352d3ec25156f8482cfefe Mon Sep 17 00:00:00 2001 From: javalsai Date: Wed, 22 Apr 2026 19:22:01 +0200 Subject: [PATCH] fix: clippy and rm old code --- Cargo.toml | 4 ++++ src/args.rs | 15 +++--------- src/main.rs | 17 -------------- src/sys.rs | 68 ++++++++++++++++++++++++++--------------------------- 4 files changed, 41 insertions(+), 63 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c53113..c682149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,10 @@ description = "Binary utility to track changes on the root filesystem on a pacma version = "0.1.0" edition = "2024" license = "GPL-3.0-only" +repository = "https://git.javalsai.tuxcord.net/rust/pacdiff" + +keywords = ["pacman", "alpm"] +categories = ["command-line-interface", "command-line-utilities", "filesystem"] [profile.release] lto = true diff --git a/src/args.rs b/src/args.rs index eed9b52..65089cb 100644 --- a/src/args.rs +++ b/src/args.rs @@ -4,9 +4,9 @@ use clap::{ArgAction, Parser, Subcommand}; #[command(version, about, long_about = None)] #[command(styles = get_clap_styles())] pub struct Args { - /// Skips certain confirmation steps. - #[arg(long = "confirm", action = ArgAction::SetTrue)] - #[arg(long = "noconfirm", action = ArgAction::SetFalse, overrides_with = "confirm")] + /// Skips certain non-interactive confirmation steps. + #[arg(long = "confirm", action = ArgAction::SetTrue, global = true)] + #[arg(long = "noconfirm", action = ArgAction::SetFalse, overrides_with = "confirm", global = true)] pub confirm: bool, #[command(subcommand)] @@ -18,15 +18,6 @@ pub enum Command { /// Looks for `.pacnew` and `.pacsave` files and allows editing of them using `$EDITOR -d /// `. Pacfiles, - - // Pacfiles { - // /// Override of `PACMAN_AUTH`. - // #[arg(short, long)] - // auth: Option, - // }, - - // Dummy argument to start working - Dummy, } const fn get_clap_styles() -> clap::builder::Styles { diff --git a/src/main.rs b/src/main.rs index 437c76f..43cf52b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,5 @@ #![feature(iterator_try_collect, once_cell_try)] -use std::io::Write; - use clap::Parser; mod args; @@ -9,27 +7,12 @@ mod commands; mod sys; fn main() -> anyhow::Result<()> { - // if unsafe { libc::geteuid() } == 0 { - // return Err(anyhow::anyhow!( - // "the program is not designed to runn as root, priviledge escalation is done by the program itself" - // )); - // } - let args = args::Args::parse(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")) - // .format(|buf, record| { - // writeln!( - // buf, - // "{}: {}", - // record.level(), - // record.args() - // ) - // }) .format_timestamp(None) .init(); match args.subcommand { args::Command::Pacfiles => commands::pacfiles(&args), - args::Command::Dummy => unimplemented!(), } } diff --git a/src/sys.rs b/src/sys.rs index 3c31bc0..4e10b09 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -1,38 +1,38 @@ -use std::{ - io, - process::{Command, Stdio}, - sync::OnceLock, -}; +// use std::{ +// io, +// process::{Command, Stdio}, +// sync::OnceLock, +// }; -pub fn get_auth() -> io::Result<&'static [String]> { - pub fn get_auth() -> io::Result> { - let mut cmd = Command::new("bash"); - let output = cmd - .args([ - "-euo", - "pipefail", - "-c", - "source /etc/makepkg.conf && \ - printf \"%s\\0\" \"${PACMAN_AUTH[@]}\"", - ]) - .stdout(Stdio::piped()) - .output()?; +// pub fn get_auth() -> io::Result<&'static [String]> { +// pub fn get_auth() -> io::Result> { +// let mut cmd = Command::new("bash"); +// let output = cmd +// .args([ +// "-euo", +// "pipefail", +// "-c", +// "source /etc/makepkg.conf && \ +// printf \"%s\\0\" \"${PACMAN_AUTH[@]}\"", +// ]) +// .stdout(Stdio::piped()) +// .output()?; - if output.status.success() { - output - .stdout - .split(|&b| b == b'\0') - .filter(|slice| !slice.is_empty()) - .map(Vec::from) - .map(String::from_utf8) - .try_collect() - .map_err(io::Error::other) - } else { - Err(io::Error::other("bash failed to source /etc/makepkg.conf")) - } - } +// if output.status.success() { +// output +// .stdout +// .split(|&b| b == b'\0') +// .filter(|slice| !slice.is_empty()) +// .map(Vec::from) +// .map(String::from_utf8) +// .try_collect() +// .map_err(io::Error::other) +// } else { +// Err(io::Error::other("bash failed to source /etc/makepkg.conf")) +// } +// } - static PACMAN_AUTH_CELL: OnceLock> = const { OnceLock::new() }; +// static PACMAN_AUTH_CELL: OnceLock> = const { OnceLock::new() }; - PACMAN_AUTH_CELL.get_or_try_init(get_auth).map(|v| v as &[_]) -} +// PACMAN_AUTH_CELL.get_or_try_init(get_auth).map(|v| v as &[_]) +// }