diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-02 22:28:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-02 23:21:32 +0100 |
| commit | 426bfdae96de84750b3d588b5ef512278eea55d7 (patch) | |
| tree | 61ba325c2bdf8d46fb91f898e67f654b356ab946 /src | |
| parent | c749136642b5f88e4603db223f443ab7e49d47d2 (diff) | |
Make list_servers() use an output function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/dcpomatic_cli.cc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 00c84767a..0303412b0 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -133,7 +133,7 @@ print_dump(function<void (string)> out, shared_ptr<Film> film) static void -list_servers () +list_servers(function <void (string)> out) { while (true) { int N = 0; @@ -144,16 +144,14 @@ list_servers () */ if (servers.empty() && Config::instance()->servers().empty()) { - cout << "No encoding servers found or configured.\n"; + out("No encoding servers found or configured.\n"); ++N; } else { - cout << std::left << setw(24) << "Host" << " Status Threads\n"; + out(fmt::format("{:24} Status Threads\n", "Host")); ++N; /* Report the state of configured servers */ for (auto i: Config::instance()->servers()) { - cout << std::left << setw(24) << i << " "; - /* See if this server is on the active list; if so, remove it and note the number of threads it is offering. */ @@ -171,9 +169,9 @@ list_servers () } } if (static_cast<bool>(threads)) { - cout << "UP " << threads.get() << "\n"; + out(fmt::format("{:24} UP {}\n", i, threads.get())); } else { - cout << "DOWN\n"; + out(fmt::format("{:24} DOWN\n", i)); } ++N; } @@ -181,9 +179,9 @@ list_servers () /* Now report any left that have been found by broadcast */ for (auto const& i: servers) { if (i.current_link_version()) { - cout << std::left << setw(24) << i.host_name() << " UP " << i.threads() << "\n"; + out(fmt::format("{:24} UP {}\n", i.host_name(), i.threads())); } else { - cout << std::left << setw(24) << i.host_name() << " bad version\n"; + out(fmt::format("{:24} bad version\n", i.host_name())); } ++N; } @@ -192,7 +190,7 @@ list_servers () dcpomatic_sleep_seconds (1); for (int i = 0; i < N; ++i) { - cout << "\033[1A\033[2K"; + out("\033[1A\033[2K"); } } } @@ -386,7 +384,7 @@ main (int argc, char* argv[]) } if (list_servers_) { - list_servers (); + list_servers([](string s) { cout << s; }); exit (EXIT_SUCCESS); } |
