test/DumpDatabase: remove the "PLUGIN" parameter, load from config file
This commit is contained in:
parent
4ed8313954
commit
7c13666226
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "db/Registry.hxx"
|
#include "db/Registry.hxx"
|
||||||
#include "db/DatabasePlugin.hxx"
|
#include "db/Configured.hxx"
|
||||||
#include "db/Interface.hxx"
|
#include "db/Interface.hxx"
|
||||||
#include "db/Selection.hxx"
|
#include "db/Selection.hxx"
|
||||||
#include "db/DatabaseListener.hxx"
|
#include "db/DatabaseListener.hxx"
|
||||||
|
@ -83,19 +83,12 @@ DumpPlaylist(const PlaylistInfo &playlist, const LightDirectory &directory)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
try {
|
try {
|
||||||
if (argc != 3) {
|
if (argc != 2) {
|
||||||
fmt::print(stderr, "Usage: DumpDatabase CONFIG PLUGIN\n");
|
fmt::print(stderr, "Usage: DumpDatabase CONFIG\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FromNarrowPath config_path = argv[1];
|
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 */
|
/* initialize MPD */
|
||||||
|
|
||||||
|
@ -109,14 +102,10 @@ try {
|
||||||
|
|
||||||
/* do it */
|
/* do it */
|
||||||
|
|
||||||
const auto *path = config.GetParam(ConfigOption::DB_FILE);
|
auto db = CreateConfiguredDatabase(config,
|
||||||
ConfigBlock block(path != nullptr ? path->line : -1);
|
init.GetEventLoop(),
|
||||||
if (path != nullptr)
|
init.GetEventLoop(),
|
||||||
block.AddBlockParam("path", path->value, path->line);
|
database_listener);
|
||||||
|
|
||||||
auto db = plugin->create(init.GetEventLoop(),
|
|
||||||
init.GetEventLoop(),
|
|
||||||
database_listener, block);
|
|
||||||
|
|
||||||
db->Open();
|
db->Open();
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,8 @@ if enable_database
|
||||||
executable(
|
executable(
|
||||||
'DumpDatabase',
|
'DumpDatabase',
|
||||||
'DumpDatabase.cxx',
|
'DumpDatabase.cxx',
|
||||||
|
'../src/db/Configured.cxx',
|
||||||
|
'../src/db/DatabaseGlue.cxx',
|
||||||
'../src/db/Registry.cxx',
|
'../src/db/Registry.cxx',
|
||||||
'../src/db/Selection.cxx',
|
'../src/db/Selection.cxx',
|
||||||
'../src/db/PlaylistVector.cxx',
|
'../src/db/PlaylistVector.cxx',
|
||||||
|
|
Loading…
Reference in New Issue