Skip to content

Commit

Permalink
cli: Progress bars miss newlines on non-interactive output
Browse files Browse the repository at this point in the history
Resolves: #1058
  • Loading branch information
m-blaha committed Dec 8, 2023
1 parent 8091c79 commit 8cb022d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions libdnf5-cli/progressbar/multi_progress_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,14 @@ std::size_t MultiProgressBar::get_total_num_of_bars() const noexcept {
std::ostream & operator<<(std::ostream & stream, MultiProgressBar & mbar) {
const bool is_interactive{tty::is_interactive()};

if (is_interactive) {
if (mbar.num_of_lines_to_clear > 0) {
stream << tty::clear_line;
for (std::size_t i = 1; i < mbar.num_of_lines_to_clear; i++) {
stream << tty::cursor_up << tty::clear_line;
}
stream << "\r";
} else if (mbar.line_printed) {
stream << std::endl;
if (is_interactive && mbar.num_of_lines_to_clear > 0) {
stream << tty::clear_line;
for (std::size_t i = 1; i < mbar.num_of_lines_to_clear; i++) {
stream << tty::cursor_up << tty::clear_line;
}
stream << "\r";
} else if (mbar.line_printed) {
stream << std::endl;
}
mbar.num_of_lines_to_clear = 0;
mbar.line_printed = false;
Expand Down

0 comments on commit 8cb022d

Please sign in to comment.