Add an explicit (-e) option to the query command.

This can be used in combination with the  --aur, --repo,
--info option or without any option.

It is used to display explicitly installed packages
and corresponds to the `pacman --Qe` command.
i18n
Jan Fooken 2 years ago
parent 5315b76ee8
commit 4bed3d5574
Failed to extract signature

@ -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

@ -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<String>,

@ -101,6 +101,7 @@ impl PacmanInstallBuilder {
pub struct PacmanQueryBuilder {
query_type: PacmanQueryType,
color: PacmanColor,
explicit: bool,
packages: Vec<String>,
}
@ -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)
}
}

@ -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);

Loading…
Cancel
Save