Skip to content

Commit 2f411e5

Browse files
committed
[cli] Silence status messages and progress in non-live TTYs
1 parent 58e0502 commit 2f411e5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/client/cli/cmd/animated_spinner.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ mp::AnimatedSpinner::~AnimatedSpinner()
4242

4343
void mp::AnimatedSpinner::start(const std::string& start_message)
4444
{
45+
if (!is_live)
46+
return;
47+
4548
std::unique_lock<decltype(mutex)> lock{mutex};
4649
if (!running)
4750
{
4851
current_message = start_message;
4952
running = true;
5053

51-
if (is_live)
52-
{
53-
clear_line(cout);
54-
cout << start_message << " " << std::flush;
55-
t = std::thread(&AnimatedSpinner::draw, this);
56-
}
54+
clear_line(cout);
55+
cout << start_message << " " << std::flush;
56+
t = std::thread(&AnimatedSpinner::draw, this);
5757
}
5858
}
5959

@@ -65,6 +65,9 @@ void mp::AnimatedSpinner::start()
6565

6666
void mp::AnimatedSpinner::stop()
6767
{
68+
if(!is_live)
69+
return;
70+
6871
std::unique_lock<decltype(mutex)> lock{mutex};
6972
if (running)
7073
{
@@ -75,12 +78,15 @@ void mp::AnimatedSpinner::stop()
7578
t.join();
7679
}
7780

78-
if (is_live)
79-
clear_line(cout);
81+
82+
clear_line(cout);
8083
}
8184

8285
void mp::AnimatedSpinner::print(std::ostream& stream, const std::string& message)
8386
{
87+
if (!is_live)
88+
return;
89+
8490
stop();
8591

8692
stream << message;

0 commit comments

Comments
 (0)