diff --git a/i18n/en/Amethyst.ftl b/i18n/en/Amethyst.ftl index 1a76c38..756c618 100644 --- a/i18n/en/Amethyst.ftl +++ b/i18n/en/Amethyst.ftl @@ -175,6 +175,7 @@ install-by = Searches by a specific field remove-packages = The name of the package(s) to remove query-aur = Lists AUR/foreign packages [-Qa, -Qm] query-repo = Lists repo/native packages [-Qr, -Qn] +query-explicit = Lists explicitly installed packages [-Qe] query-info = Get information about a specific package query-owns = Get information about which package owns a file upgrade-repo = Upgrades only repo/native packages diff --git a/src/args.rs b/src/args.rs index 6c8ead1..95b1a37 100644 --- a/src/args.rs +++ b/src/args.rs @@ -102,6 +102,9 @@ pub struct QueryArgs { #[arg(long, short, help = fl!("query-repo"))] pub repo: bool, + #[arg(long, short, help = fl!("query-explicit"))] + pub explicit: bool, + #[arg(long, short, help = fl!("query-info"))] pub info: Option, diff --git a/src/builder/pacman.rs b/src/builder/pacman.rs index 5326911..7a28ea7 100644 --- a/src/builder/pacman.rs +++ b/src/builder/pacman.rs @@ -101,6 +101,7 @@ impl PacmanInstallBuilder { pub struct PacmanQueryBuilder { query_type: PacmanQueryType, color: PacmanColor, + explicit: bool, packages: Vec, } @@ -133,6 +134,7 @@ impl PacmanQueryBuilder { Self { query_type, color: PacmanColor::default(), + explicit: false, packages: Vec::new(), } } @@ -181,6 +183,12 @@ impl PacmanQueryBuilder { self } + pub fn explicit(mut self, explicit: bool) -> Self { + self.explicit = explicit; + + self + } + #[tracing::instrument(level = "trace")] pub async fn query(self) -> AppResult<()> { self.build_command().wait_success().await @@ -234,6 +242,10 @@ impl PacmanQueryBuilder { PacmanColor::Never => command.arg("never"), }; + if self.explicit { + command = command.arg("--explicit") + } + command.args(self.packages) } } diff --git a/src/main.rs b/src/main.rs index f6f49c6..446acb5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -185,6 +185,7 @@ async fn cmd_query(args: QueryArgs) { fl_info!("installed-repo-packages"); PacmanQueryBuilder::native() .color(PacmanColor::Always) + .explicit(args.explicit) .query() .await .silent_unwrap(AppExitCode::PacmanError); @@ -194,6 +195,7 @@ async fn cmd_query(args: QueryArgs) { fl_info!("installed-aur-packages"); PacmanQueryBuilder::foreign() .color(PacmanColor::Always) + .explicit(args.explicit) .query() .await .silent_unwrap(AppExitCode::PacmanError); @@ -203,6 +205,7 @@ async fn cmd_query(args: QueryArgs) { fl_info!("installed-packages"); PacmanQueryBuilder::all() .color(PacmanColor::Always) + .explicit(args.explicit) .query() .await .silent_unwrap(AppExitCode::PacmanError); @@ -211,6 +214,7 @@ async fn cmd_query(args: QueryArgs) { if let Some(info) = args.info { PacmanQueryBuilder::info() .package(info) + .explicit(args.explicit) .query() .await .silent_unwrap(AppExitCode::PacmanError);