CommandLine: use libfmt

This commit is contained in:
Max Kellermann 2023-03-12 08:56:24 +01:00
parent 5388759bd5
commit 27d3dcf14c
1 changed files with 79 additions and 77 deletions

View File

@ -55,6 +55,8 @@
#include "archive/ArchivePlugin.hxx"
#endif
#include <fmt/core.h>
namespace {
#ifdef _WIN32
constexpr auto CONFIG_FILE_LOCATION = Path::FromFS(PATH_LITERAL("mpd\\mpd.conf"));
@ -101,7 +103,7 @@ static constexpr Domain cmdline_domain("cmdline");
[[noreturn]]
static void version()
{
printf("Music Player Daemon " VERSION " (%s)"
fmt::print("Music Player Daemon " VERSION " ({})"
"\n"
"Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
"Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>\n"
@ -110,49 +112,49 @@ static void version()
GIT_VERSION);
#ifdef ENABLE_DATABASE
printf("\n"
fmt::print("\n"
"Database plugins:\n");
for (auto i = database_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
fmt::print(" {}", (*i)->name);
printf("\n\n"
fmt::print("\n\n"
"Storage plugins:\n");
for (auto i = storage_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
fmt::print(" {}", (*i)->name);
printf("\n");
fmt::print("\n");
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
printf("\n"
fmt::print("\n"
"Neighbor plugins:\n");
for (auto i = neighbor_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
fmt::print(" {}", (*i)->name);
#endif
printf("\n"
fmt::print("\n"
"\n"
"Decoders plugins:\n");
decoder_plugins_for_each([](const DecoderPlugin &plugin){
printf(" [%s]", plugin.name);
fmt::print(" [{}]", plugin.name);
const char *const*suffixes = plugin.suffixes;
if (suffixes != nullptr)
for (; *suffixes != nullptr; ++suffixes)
printf(" %s", *suffixes);
fmt::print(" {}", *suffixes);
if (plugin.protocols != nullptr)
for (const auto &i : plugin.protocols())
printf(" %s", i.c_str());
fmt::print(" {}", i);
printf("\n");
fmt::print("\n");
});
printf("\n"
fmt::print("\n"
"Filters:\n"
#ifdef ENABLE_LIBSAMPLERATE
" libsamplerate"
@ -168,32 +170,32 @@ static void version()
"\n\n"
"Output plugins:\n");
audio_output_plugins_for_each(plugin)
printf(" %s", plugin->name);
printf("\n"
fmt::print(" {}", plugin->name);
fmt::print("\n"
#ifdef ENABLE_ENCODER
"\n"
"Encoder plugins:\n");
encoder_plugins_for_each(plugin)
printf(" %s", plugin->name);
printf("\n"
fmt::print(" {}", plugin->name);
fmt::print("\n"
#endif
#ifdef ENABLE_ARCHIVE
"\n"
"Archive plugins:\n");
archive_plugins_for_each(plugin) {
printf(" [%s]", plugin->name);
fmt::print(" [{}]", plugin->name);
const char *const*suffixes = plugin->suffixes;
if (suffixes != nullptr)
for (; *suffixes != nullptr; ++suffixes)
printf(" %s", *suffixes);
fmt::print(" {}", *suffixes);
printf("\n");
fmt::print("\n");
}
printf(""
fmt::print(""
#endif
"\n"
@ -207,18 +209,18 @@ static void version()
#endif
);
input_plugins_for_each(plugin)
printf(" %s", plugin->name);
fmt::print(" {}", plugin->name);
printf("\n\n"
fmt::print("\n\n"
"Playlist plugins:\n");
playlist_plugins_for_each(plugin)
printf(" %s", plugin->name);
fmt::print(" {}", plugin->name);
printf("\n\n"
fmt::print("\n\n"
"Protocols:\n");
print_supported_uri_schemes_to_fp(stdout);
printf("\n"
fmt::print("\n"
"Other features:\n"
#ifdef HAVE_AVAHI
" avahi"
@ -274,7 +276,7 @@ static void PrintOption(const OptionDef &opt)
[[noreturn]]
static void help()
{
printf("Usage:\n"
fmt::print("Usage:\n"
" mpd [OPTION...] [path/to/mpd.conf]\n"
"\n"
"Music Player Daemon - a daemon for playing music.\n"