fix: clippy and rm old code
This commit is contained in:
@@ -4,6 +4,10 @@ description = "Binary utility to track changes on the root filesystem on a pacma
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "GPL-3.0-only"
|
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]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|||||||
+3
-12
@@ -4,9 +4,9 @@ use clap::{ArgAction, Parser, Subcommand};
|
|||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
#[command(styles = get_clap_styles())]
|
#[command(styles = get_clap_styles())]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
/// Skips certain confirmation steps.
|
/// Skips certain non-interactive confirmation steps.
|
||||||
#[arg(long = "confirm", action = ArgAction::SetTrue)]
|
#[arg(long = "confirm", action = ArgAction::SetTrue, global = true)]
|
||||||
#[arg(long = "noconfirm", action = ArgAction::SetFalse, overrides_with = "confirm")]
|
#[arg(long = "noconfirm", action = ArgAction::SetFalse, overrides_with = "confirm", global = true)]
|
||||||
pub confirm: bool,
|
pub confirm: bool,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -18,15 +18,6 @@ pub enum Command {
|
|||||||
/// Looks for `.pacnew` and `.pacsave` files and allows editing of them using `$EDITOR -d <file>
|
/// Looks for `.pacnew` and `.pacsave` files and allows editing of them using `$EDITOR -d <file>
|
||||||
/// <pacfile>`.
|
/// <pacfile>`.
|
||||||
Pacfiles,
|
Pacfiles,
|
||||||
|
|
||||||
// Pacfiles {
|
|
||||||
// /// Override of `PACMAN_AUTH`.
|
|
||||||
// #[arg(short, long)]
|
|
||||||
// auth: Option<String>,
|
|
||||||
// },
|
|
||||||
|
|
||||||
// Dummy argument to start working
|
|
||||||
Dummy,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn get_clap_styles() -> clap::builder::Styles {
|
const fn get_clap_styles() -> clap::builder::Styles {
|
||||||
|
|||||||
-17
@@ -1,7 +1,5 @@
|
|||||||
#![feature(iterator_try_collect, once_cell_try)]
|
#![feature(iterator_try_collect, once_cell_try)]
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
mod args;
|
mod args;
|
||||||
@@ -9,27 +7,12 @@ mod commands;
|
|||||||
mod sys;
|
mod sys;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
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();
|
let args = args::Args::parse();
|
||||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace"))
|
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)
|
.format_timestamp(None)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
match args.subcommand {
|
match args.subcommand {
|
||||||
args::Command::Pacfiles => commands::pacfiles(&args),
|
args::Command::Pacfiles => commands::pacfiles(&args),
|
||||||
args::Command::Dummy => unimplemented!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-34
@@ -1,38 +1,38 @@
|
|||||||
use std::{
|
// use std::{
|
||||||
io,
|
// io,
|
||||||
process::{Command, Stdio},
|
// process::{Command, Stdio},
|
||||||
sync::OnceLock,
|
// sync::OnceLock,
|
||||||
};
|
// };
|
||||||
|
|
||||||
pub fn get_auth() -> io::Result<&'static [String]> {
|
// pub fn get_auth() -> io::Result<&'static [String]> {
|
||||||
pub fn get_auth() -> io::Result<Vec<String>> {
|
// pub fn get_auth() -> io::Result<Vec<String>> {
|
||||||
let mut cmd = Command::new("bash");
|
// let mut cmd = Command::new("bash");
|
||||||
let output = cmd
|
// let output = cmd
|
||||||
.args([
|
// .args([
|
||||||
"-euo",
|
// "-euo",
|
||||||
"pipefail",
|
// "pipefail",
|
||||||
"-c",
|
// "-c",
|
||||||
"source /etc/makepkg.conf && \
|
// "source /etc/makepkg.conf && \
|
||||||
printf \"%s\\0\" \"${PACMAN_AUTH[@]}\"",
|
// printf \"%s\\0\" \"${PACMAN_AUTH[@]}\"",
|
||||||
])
|
// ])
|
||||||
.stdout(Stdio::piped())
|
// .stdout(Stdio::piped())
|
||||||
.output()?;
|
// .output()?;
|
||||||
|
|
||||||
if output.status.success() {
|
// if output.status.success() {
|
||||||
output
|
// output
|
||||||
.stdout
|
// .stdout
|
||||||
.split(|&b| b == b'\0')
|
// .split(|&b| b == b'\0')
|
||||||
.filter(|slice| !slice.is_empty())
|
// .filter(|slice| !slice.is_empty())
|
||||||
.map(Vec::from)
|
// .map(Vec::from)
|
||||||
.map(String::from_utf8)
|
// .map(String::from_utf8)
|
||||||
.try_collect()
|
// .try_collect()
|
||||||
.map_err(io::Error::other)
|
// .map_err(io::Error::other)
|
||||||
} else {
|
// } else {
|
||||||
Err(io::Error::other("bash failed to source /etc/makepkg.conf"))
|
// Err(io::Error::other("bash failed to source /etc/makepkg.conf"))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
static PACMAN_AUTH_CELL: OnceLock<Vec<String>> = const { OnceLock::new() };
|
// static PACMAN_AUTH_CELL: OnceLock<Vec<String>> = 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 &[_])
|
||||||
}
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user