Skip to content

Commit

Permalink
feat(-A): prompt if the user tries to install an ignored package
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Jun 5, 2024
1 parent 8e6c356 commit 3b0f825
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions rust/aura-pm/i18n/en-US/aura_pm.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A-install-deps = Resolving dependencies...
A-install-repo-pkgs = Repository dependencies:
A-install-aur-pkgs = AUR packages:
A-install-path-comp = Failed to extract final component of: { $path }
A-install-ignored = { $file } is marked "ignored". Install anyway?
A-build-prep = Preparing build directories...
A-build-pkg = Building { $pkg }...
Expand Down
13 changes: 12 additions & 1 deletion rust/aura-pm/src/command/aur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,18 @@ pub(crate) fn install<'a, I>(
where
I: IntoIterator<Item = &'a str>,
{
let pkgs: Vec<_> = raw_pkgs.into_iter().collect();
let pkgs: Vec<_> = raw_pkgs
.into_iter()
.filter(|p| {
// Prompt if the user specified packages that are marked "ignored".
if env.aur.ignores.contains(*p) {
let pkg = p.bold().cyan().to_string();
proceed!(fll, "A-install-ignored", file = pkg).is_some()
} else {
true
}
})
.collect();

// Exit early if the user passed no packages.
if pkgs.is_empty() {
Expand Down
8 changes: 8 additions & 0 deletions rust/aura-pm/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ macro_rules! executable {
#[macro_export]
/// Ask for permission to proceed, but with a custom message.
macro_rules! proceed {
($fll:expr, $msg:expr, $($arg:expr),*) => {{
let formatted = format!(
"{} {} ",
i18n_embed_fl::fl!($fll, $msg, $($arg)*),
i18n_embed_fl::fl!($fll, "proceed-yes")
);
$crate::utils::prompt(&$crate::a!(formatted))
}};
($fll:expr, $msg:expr) => {{
let formatted = format!(
"{} {} ",
Expand Down

0 comments on commit 3b0f825

Please sign in to comment.