Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make output less vebose in --quiet mode #2001

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions dnf5/commands/list/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ void ListCommand::run() {
config.get_color_list_available_reinstall_option().get_value(),
config.get_color_list_available_upgrade_option().get_value());

auto heading = "";

switch (pkg_narrow) {
case PkgNarrow::ALL: {
libdnf5::rpm::PackageQuery available(base_query);
Expand All @@ -196,7 +198,10 @@ void ListCommand::run() {
break;
}
case PkgNarrow::INSTALLED: {
package_matched |= sections->add_section(_("Installed packages"), installed);
if (!ctx.get_quiet()) {
heading = _("Installed packages");
}
package_matched |= sections->add_section(heading, installed);
break;
}
case PkgNarrow::AVAILABLE: {
Expand All @@ -205,15 +210,21 @@ void ListCommand::run() {
base_query.filter_priority();
base_query.filter_latest_evr();
}
package_matched |= sections->add_section(_("Available packages"), base_query);
if (!ctx.get_quiet()) {
heading = _("Available packages");
}
package_matched |= sections->add_section(heading, base_query);
break;
}
case PkgNarrow::UPGRADES:
base_query.filter_priority();
base_query.filter_upgrades();
base_query.filter_arch(std::vector<std::string>{"src", "nosrc"}, libdnf5::sack::QueryCmp::NEQ);
base_query.filter_latest_evr();
package_matched |= sections->add_section(_("Available upgrades"), base_query);
if (!ctx.get_quiet()) {
heading = _("Available upgrades");
}
package_matched |= sections->add_section(heading, base_query);
break;
case PkgNarrow::OBSOLETES: {
base_query.filter_priority();
Expand All @@ -229,16 +240,25 @@ void ListCommand::run() {
}
obsoletes.emplace(pkg.get_id(), obsoleted);
}
package_matched |= sections->add_section(_("Obsoleting packages"), base_query, obsoletes);
if (!ctx.get_quiet()) {
heading = _("Obsoleting packages");
}
package_matched |= sections->add_section(heading, base_query, obsoletes);
break;
}
case PkgNarrow::AUTOREMOVE:
installed.filter_unneeded();
package_matched |= sections->add_section(_("Autoremove packages"), installed);
if (!ctx.get_quiet()) {
heading = _("Autoremove packages");
}
package_matched |= sections->add_section(heading, installed);
break;
case PkgNarrow::EXTRAS:
base_query.filter_extras();
package_matched |= sections->add_section(_("Extra packages"), base_query);
if (!ctx.get_quiet()) {
heading = _("Extra packages");
}
package_matched |= sections->add_section(heading, base_query);
break;
case PkgNarrow::RECENT:
base_query.filter_available();
Expand All @@ -249,7 +269,10 @@ void ListCommand::run() {
auto recent_limit_days = config.get_recent_option().get_value();
auto now = time(NULL);
base_query.filter_recent(now - (recent_limit_days * 86400));
package_matched |= sections->add_section(_("Recently added packages"), base_query);
if (!ctx.get_quiet()) {
heading = _("Recently added packages");
}
package_matched |= sections->add_section(heading, base_query);
break;
}

Expand Down
4 changes: 1 addition & 3 deletions dnf5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ void RootCommand::set_argument_parser() {
auto quiet = parser.add_new_named_arg("quiet");
quiet->set_long_name("quiet");
quiet->set_short_name('q');
quiet->set_description(
_("In combination with a non-interactive command, shows just the relevant content. "
"Suppresses messages notifying about the current state or actions of dnf5."));
quiet->set_description(_("Show less messages."));
quiet->set_parse_hook_func([&ctx](
[[maybe_unused]] ArgumentParser::NamedArg * arg,
[[maybe_unused]] const char * option,
Expand Down
Loading