CommandLine: use libfmt
This commit is contained in:
parent
5388759bd5
commit
27d3dcf14c
@ -55,6 +55,8 @@
|
|||||||
#include "archive/ArchivePlugin.hxx"
|
#include "archive/ArchivePlugin.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
constexpr auto CONFIG_FILE_LOCATION = Path::FromFS(PATH_LITERAL("mpd\\mpd.conf"));
|
constexpr auto CONFIG_FILE_LOCATION = Path::FromFS(PATH_LITERAL("mpd\\mpd.conf"));
|
||||||
@ -101,159 +103,159 @@ static constexpr Domain cmdline_domain("cmdline");
|
|||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
static void version()
|
static void version()
|
||||||
{
|
{
|
||||||
printf("Music Player Daemon " VERSION " (%s)"
|
fmt::print("Music Player Daemon " VERSION " ({})"
|
||||||
"\n"
|
"\n"
|
||||||
"Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
|
"Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
|
||||||
"Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>\n"
|
"Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>\n"
|
||||||
"This is free software; see the source for copying conditions. There is NO\n"
|
"This is free software; see the source for copying conditions. There is NO\n"
|
||||||
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
|
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
|
||||||
GIT_VERSION);
|
GIT_VERSION);
|
||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
"Database plugins:\n");
|
"Database plugins:\n");
|
||||||
|
|
||||||
for (auto i = database_plugins; *i != nullptr; ++i)
|
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");
|
"Storage plugins:\n");
|
||||||
|
|
||||||
for (auto i = storage_plugins; *i != nullptr; ++i)
|
for (auto i = storage_plugins; *i != nullptr; ++i)
|
||||||
printf(" %s", (*i)->name);
|
fmt::print(" {}", (*i)->name);
|
||||||
|
|
||||||
printf("\n");
|
fmt::print("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
"Neighbor plugins:\n");
|
"Neighbor plugins:\n");
|
||||||
for (auto i = neighbor_plugins; *i != nullptr; ++i)
|
for (auto i = neighbor_plugins; *i != nullptr; ++i)
|
||||||
printf(" %s", (*i)->name);
|
fmt::print(" {}", (*i)->name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Decoders plugins:\n");
|
"Decoders plugins:\n");
|
||||||
|
|
||||||
decoder_plugins_for_each([](const DecoderPlugin &plugin){
|
decoder_plugins_for_each([](const DecoderPlugin &plugin){
|
||||||
printf(" [%s]", plugin.name);
|
fmt::print(" [{}]", plugin.name);
|
||||||
|
|
||||||
const char *const*suffixes = plugin.suffixes;
|
const char *const*suffixes = plugin.suffixes;
|
||||||
if (suffixes != nullptr)
|
if (suffixes != nullptr)
|
||||||
for (; *suffixes != nullptr; ++suffixes)
|
for (; *suffixes != nullptr; ++suffixes)
|
||||||
printf(" %s", *suffixes);
|
fmt::print(" {}", *suffixes);
|
||||||
|
|
||||||
if (plugin.protocols != nullptr)
|
if (plugin.protocols != nullptr)
|
||||||
for (const auto &i : plugin.protocols())
|
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"
|
"Filters:\n"
|
||||||
#ifdef ENABLE_LIBSAMPLERATE
|
#ifdef ENABLE_LIBSAMPLERATE
|
||||||
" libsamplerate"
|
" libsamplerate"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SOXR
|
#ifdef ENABLE_SOXR
|
||||||
" soxr"
|
" soxr"
|
||||||
#endif
|
#endif
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Tag plugins:\n"
|
"Tag plugins:\n"
|
||||||
#ifdef ENABLE_ID3TAG
|
#ifdef ENABLE_ID3TAG
|
||||||
" id3tag"
|
" id3tag"
|
||||||
#endif
|
#endif
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Output plugins:\n");
|
"Output plugins:\n");
|
||||||
audio_output_plugins_for_each(plugin)
|
audio_output_plugins_for_each(plugin)
|
||||||
printf(" %s", plugin->name);
|
fmt::print(" {}", plugin->name);
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
|
|
||||||
#ifdef ENABLE_ENCODER
|
#ifdef ENABLE_ENCODER
|
||||||
"\n"
|
"\n"
|
||||||
"Encoder plugins:\n");
|
"Encoder plugins:\n");
|
||||||
encoder_plugins_for_each(plugin)
|
encoder_plugins_for_each(plugin)
|
||||||
printf(" %s", plugin->name);
|
fmt::print(" {}", plugin->name);
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
"\n"
|
"\n"
|
||||||
"Archive plugins:\n");
|
"Archive plugins:\n");
|
||||||
archive_plugins_for_each(plugin) {
|
archive_plugins_for_each(plugin) {
|
||||||
printf(" [%s]", plugin->name);
|
fmt::print(" [{}]", plugin->name);
|
||||||
|
|
||||||
const char *const*suffixes = plugin->suffixes;
|
const char *const*suffixes = plugin->suffixes;
|
||||||
if (suffixes != nullptr)
|
if (suffixes != nullptr)
|
||||||
for (; *suffixes != nullptr; ++suffixes)
|
for (; *suffixes != nullptr; ++suffixes)
|
||||||
printf(" %s", *suffixes);
|
fmt::print(" {}", *suffixes);
|
||||||
|
|
||||||
printf("\n");
|
fmt::print("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(""
|
fmt::print(""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
"Input plugins:\n"
|
"Input plugins:\n"
|
||||||
" file"
|
" file"
|
||||||
#ifdef HAVE_URING
|
#ifdef HAVE_URING
|
||||||
" io_uring"
|
" io_uring"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
" archive"
|
" archive"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
input_plugins_for_each(plugin)
|
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:\n");
|
||||||
playlist_plugins_for_each(plugin)
|
playlist_plugins_for_each(plugin)
|
||||||
printf(" %s", plugin->name);
|
fmt::print(" {}", plugin->name);
|
||||||
|
|
||||||
printf("\n\n"
|
fmt::print("\n\n"
|
||||||
"Protocols:\n");
|
"Protocols:\n");
|
||||||
print_supported_uri_schemes_to_fp(stdout);
|
print_supported_uri_schemes_to_fp(stdout);
|
||||||
|
|
||||||
printf("\n"
|
fmt::print("\n"
|
||||||
"Other features:\n"
|
"Other features:\n"
|
||||||
#ifdef HAVE_AVAHI
|
#ifdef HAVE_AVAHI
|
||||||
" avahi"
|
" avahi"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_DBUS
|
#ifdef ENABLE_DBUS
|
||||||
" dbus"
|
" dbus"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_UDISKS
|
#ifdef ENABLE_UDISKS
|
||||||
" udisks"
|
" udisks"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EPOLL
|
#ifdef USE_EPOLL
|
||||||
" epoll"
|
" epoll"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
" iconv"
|
" iconv"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ICU
|
#ifdef HAVE_ICU
|
||||||
" icu"
|
" icu"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_INOTIFY
|
#ifdef ENABLE_INOTIFY
|
||||||
" inotify"
|
" inotify"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
" ipv6"
|
" ipv6"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SYSTEMD_DAEMON
|
#ifdef ENABLE_SYSTEMD_DAEMON
|
||||||
" systemd"
|
" systemd"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TCP
|
#ifdef HAVE_TCP
|
||||||
" tcp"
|
" tcp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
" un"
|
" un"
|
||||||
#endif
|
#endif
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
std::exit(EXIT_SUCCESS);
|
std::exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
@ -274,12 +276,12 @@ static void PrintOption(const OptionDef &opt)
|
|||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
static void help()
|
static void help()
|
||||||
{
|
{
|
||||||
printf("Usage:\n"
|
fmt::print("Usage:\n"
|
||||||
" mpd [OPTION...] [path/to/mpd.conf]\n"
|
" mpd [OPTION...] [path/to/mpd.conf]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Music Player Daemon - a daemon for playing music.\n"
|
"Music Player Daemon - a daemon for playing music.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n");
|
"Options:\n");
|
||||||
|
|
||||||
for (const auto &i : option_defs)
|
for (const auto &i : option_defs)
|
||||||
if(i.HasDescription()) // hide hidden options from help print
|
if(i.HasDescription()) // hide hidden options from help print
|
||||||
|
Loading…
Reference in New Issue
Block a user