From 0e73f49128d0c66e21aad1e1653beb3f71ab436c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Fri, 3 Jan 2025 12:20:21 +0100 Subject: [PATCH] Add a hint to `history info` without trans IDs when no match found When the default value of the transaction ID argument is only `last` users searching for transactions with specific packages might be confused why the output is empty. For example: ``` $ dnf5 history info --contains-pkgs=htop ``` Would search only the last transaction. On the other hand `list` works as expected: ``` $ dnf5 history list --contains-pkgs=htop ``` It searches all transactions becuase the default for `list` is all transactions. --- dnf5/commands/history/history_info.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dnf5/commands/history/history_info.cpp b/dnf5/commands/history/history_info.cpp index 9e25d0f08..da47499c9 100644 --- a/dnf5/commands/history/history_info.cpp +++ b/dnf5/commands/history/history_info.cpp @@ -60,9 +60,17 @@ void HistoryInfoCommand::run() { std::sort(transactions.begin(), transactions.end()); } - for (auto ts : transactions) { - libdnf5::cli::output::print_transaction_info(ts); - std::cout << std::endl; + if (!transactions.empty()) { + for (auto ts : transactions) { + libdnf5::cli::output::print_transaction_info(ts); + std::cout << std::endl; + } + } else { + if (ts_specs.empty()) { + std::cout << _("No match found, history info defaults to considering only the last transaction, specify " + "\"1..last\" range to search all transactions.") + << std::endl; + } } }