cli: Method to drop the last progress bar message

Useful to create "temporary" messages, will be used to reduce the
"Running scriptlet" / "Stop scriptlet" rpm transaction noise.
This commit is contained in:
Marek Blaha 2024-08-02 13:24:17 +02:00 committed by Neal Gompa (ニール・ゴンパ)
parent 04d9908f59
commit 95f6b67a60
2 changed files with 9 additions and 0 deletions

View File

@ -95,6 +95,8 @@ public:
// 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

View File

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