diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-02 22:32:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-02 23:21:32 +0100 |
| commit | 740e0a31f0f6f2ab6d84ccc1c0f24165ce9ccad6 (patch) | |
| tree | 1a89198ba44b90945e5f3c8bca2a19430ce87f36 /src/tools | |
| parent | 426bfdae96de84750b3d588b5ef512278eea55d7 (diff) | |
Make show_jobs_on_console() use output and flush functions.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic_cli.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 0303412b0..ce54b52a2 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -197,7 +197,7 @@ list_servers(function <void (string)> out) bool -show_jobs_on_console (bool progress) +show_jobs_on_console(function<void (string)> out, function<void ()> flush, bool progress) { bool first = true; bool error = false; @@ -209,25 +209,25 @@ show_jobs_on_console (bool progress) if (!first && progress) { for (size_t i = 0; i < jobs.size(); ++i) { - cout << UP_ONE_LINE_AND_ERASE; + out(UP_ONE_LINE_AND_ERASE); } - cout.flush (); + flush(); } first = false; for (auto i: jobs) { if (progress) { - cout << i->name(); + out(i->name()); if (!i->sub_name().empty()) { - cout << "; " << i->sub_name(); + out(fmt::format("; {}", i->sub_name())); } - cout << ": "; + out(": "); if (i->progress ()) { - cout << i->status() << " \n"; + out(fmt::format("{} \n", i->status())); } else { - cout << ": Running \n"; + out(": Running \n"); } } @@ -235,7 +235,7 @@ show_jobs_on_console (bool progress) /* We won't see this error if we haven't been showing progress, so show it now. */ - cout << i->status() << "\n"; + out(fmt::format("{}\n", i->status())); } if (i->finished_in_error()) { @@ -528,7 +528,7 @@ main (int argc, char* argv[]) } } - bool const error = show_jobs_on_console (progress); + bool const error = show_jobs_on_console([](string s) { cout << s; }, []() { cout.flush(); }, progress); if (keep_going) { while (true) { |
