feat: implement --noconfirm

This commit is contained in:
steven-omaha
2023-05-12 16:05:49 +02:00
parent f03805446e
commit 7d9f444ea6
10 changed files with 94 additions and 29 deletions
+16 -3
View File
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use anyhow::{Context, Result};
use clap::{Arg, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command};
use path_absolutize::Absolutize;
use crate::action::*;
@@ -100,16 +100,22 @@ fn get_group_cmd() -> Command {
fn get_package_cmd() -> Command {
let sync = Command::new(SYNC)
.about("install packages from all imported groups")
.visible_alias("sy");
.visible_alias("sy")
.arg(build_noconfirm_arg());
let clean = Command::new(CLEAN)
.about("remove unmanaged packages")
.visible_alias("c");
.visible_alias("c")
.arg(build_noconfirm_arg());
let unmanaged = Command::new(UNMANAGED)
.about("show explicitly installed packages not managed by pacdef")
.visible_alias("u");
let review = Command::new(REVIEW)
.about("review unmanaged packages")
.visible_alias("r");
let search = Command::new(SEARCH)
.visible_alias("se")
.about("search for packages which match a provided regex")
@@ -128,6 +134,13 @@ fn get_package_cmd() -> Command {
.subcommands([clean, review, unmanaged, search, sync])
}
fn build_noconfirm_arg() -> Arg {
Arg::new("noconfirm")
.long("noconfirm")
.help("do not ask for any confirmation")
.action(ArgAction::SetTrue)
}
/// Get and parse the CLI arguments.
#[must_use]
pub fn get() -> clap::ArgMatches {