Skip to content

Commit

Permalink
cli: Method to drop the last progress bar message
Browse files Browse the repository at this point in the history
Useful to create "temporary" messages, will be used to reduce the
"Running scriptlet" / "Stop scriptlet" rpm transaction noise.
  • Loading branch information
m-blaha committed Aug 2, 2024
1 parent fdc16b1 commit b3163df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/libdnf5-cli/progressbar/progress_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class LIBDNF_CLI_API ProgressBar {

// messages
void add_message(MessageType type, const std::string & message) { messages.emplace_back(type, message); }
/// remove the last message
void pop_message();
const std::vector<Message> & get_messages() const noexcept { return messages; }

// auto-finish feature; turn off if you want to handle state manually
Expand Down
7 changes: 7 additions & 0 deletions libdnf5-cli/progressbar/progress_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ void ProgressBar::set_total_ticks(int64_t value) {
}


void ProgressBar::pop_message() {
if (!messages.empty()) {
messages.pop_back();
}
}


std::ostream & operator<<(std::ostream & os, ProgressBar & bar) {
bar.to_stream(os);
return os;
Expand Down

0 comments on commit b3163df

Please sign in to comment.