From 7c13666226e535a3a4a7a4a6a7c5908daabdd054 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Jan 2024 15:28:40 +0100 Subject: [PATCH] test/DumpDatabase: remove the "PLUGIN" parameter, load from config file --- test/DumpDatabase.cxx | 25 +++++++------------------ test/meson.build | 2 ++ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index 9abb267f5..bd7c5409c 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -3,7 +3,7 @@ #include "config.h" #include "db/Registry.hxx" -#include "db/DatabasePlugin.hxx" +#include "db/Configured.hxx" #include "db/Interface.hxx" #include "db/Selection.hxx" #include "db/DatabaseListener.hxx" @@ -83,19 +83,12 @@ DumpPlaylist(const PlaylistInfo &playlist, const LightDirectory &directory) int main(int argc, char **argv) try { - if (argc != 3) { - fmt::print(stderr, "Usage: DumpDatabase CONFIG PLUGIN\n"); + if (argc != 2) { + fmt::print(stderr, "Usage: DumpDatabase CONFIG\n"); return EXIT_FAILURE; } const FromNarrowPath config_path = argv[1]; - const char *const plugin_name = argv[2]; - - const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name); - if (plugin == nullptr) { - fmt::print(stderr, "No such database plugin: {}\n", plugin_name); - return EXIT_FAILURE; - } /* initialize MPD */ @@ -109,14 +102,10 @@ try { /* do it */ - const auto *path = config.GetParam(ConfigOption::DB_FILE); - ConfigBlock block(path != nullptr ? path->line : -1); - if (path != nullptr) - block.AddBlockParam("path", path->value, path->line); - - auto db = plugin->create(init.GetEventLoop(), - init.GetEventLoop(), - database_listener, block); + auto db = CreateConfiguredDatabase(config, + init.GetEventLoop(), + init.GetEventLoop(), + database_listener); db->Open(); diff --git a/test/meson.build b/test/meson.build index 7ff5b72d2..6a9184dac 100644 --- a/test/meson.build +++ b/test/meson.build @@ -223,6 +223,8 @@ if enable_database executable( 'DumpDatabase', 'DumpDatabase.cxx', + '../src/db/Configured.cxx', + '../src/db/DatabaseGlue.cxx', '../src/db/Registry.cxx', '../src/db/Selection.cxx', '../src/db/PlaylistVector.cxx',