Merge pull request #11 from Trivernis/main

Add sudoloop
i18n
Michal 2 years ago committed by GitHub
commit 55c71069b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,10 @@ pub struct Args {
/// Complete operation without prompting user
#[clap(long = "noconfirm", global = true)]
pub no_confirm: bool,
/// Loops sudo in the background to ensure it doesn't time out during long builds
#[clap(long = "sudoloop")]
pub sudoloop: bool,
}
#[derive(Debug, Clone, Subcommand)]
@ -80,10 +84,10 @@ pub struct SearchArgs {
#[derive(Default, Debug, Clone, Parser)]
pub struct QueryArgs {
/// Lists AUR/foreign packages
#[clap(long, short)]
#[clap(long, short, from_global)]
pub aur: bool,
/// Lists repo/native packages
#[clap(long, short)]
#[clap(long, short, from_global)]
pub repo: bool,
}

@ -45,6 +45,10 @@ impl ShellCommand {
Self::new("bash")
}
pub fn sudo() -> Self {
Self::new("sudo")
}
fn new<S: ToString>(command: S) -> Self {
Self {
command: command.to_string(),

@ -15,6 +15,12 @@ mod sort;
pub mod structs;
#[macro_use]
pub(crate) mod utils;
mod sudoloop;
pub use clean::*;
pub use initialise::*;
pub use sort::*;
pub use sudoloop::*;
#[macro_export]
macro_rules! uwu {

@ -0,0 +1,16 @@
use crate::ShellCommand;
use std::thread;
use std::time::Duration;
/// Loop sudo so it doesn't time out
pub fn start_sudoloop() {
prompt_sudo();
std::thread::spawn(|| loop {
prompt_sudo();
thread::sleep(Duration::from_secs(3 * 60))
});
}
fn prompt_sudo() {
while ShellCommand::sudo().arg("-v").wait_success().is_err() {}
}

@ -6,7 +6,7 @@ use internal::error::SilentUnwrap;
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs};
use crate::internal::detect;
use crate::internal::exit_code::AppExitCode;
use crate::internal::{init, sort, structs::Options};
use crate::internal::{init, sort, start_sudoloop, structs::Options};
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -34,6 +34,10 @@ fn main() {
init(options);
if args.sudoloop {
start_sudoloop();
}
match args.subcommand.unwrap_or_default() {
Operation::Install(install_args) => cmd_install(install_args, options),
Operation::Remove(remove_args) => cmd_remove(remove_args, options),

@ -137,7 +137,7 @@ pub fn aur_install(a: Vec<String>, options: Options) {
crate::operations::aur_install(md_sorted.aur, newopts);
}
let mut makepkg_args = vec!["-rsic", "--skippgp"];
let mut makepkg_args = vec!["-rsci", "--skippgp"];
if options.asdeps {
makepkg_args.push("--asdeps")
}

Loading…
Cancel
Save