diff --git a/test/meson.build b/test/meson.build index 52833feea..b90d4fa7d 100644 --- a/test/meson.build +++ b/test/meson.build @@ -218,6 +218,7 @@ if enable_database dependencies: [ event_dep, storage_glue_dep, + cmdline_dep, ], ) diff --git a/test/run_storage.cxx b/test/run_storage.cxx index a2cde01e3..62c35438f 100644 --- a/test/run_storage.cxx +++ b/test/run_storage.cxx @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project +#include "cmdline/OptionDef.hxx" +#include "cmdline/OptionParser.hxx" #include "event/Thread.hxx" #include "storage/Registry.hxx" #include "storage/StorageInterface.hxx" @@ -11,6 +13,8 @@ #include "util/PrintException.hxx" #include "util/StringAPI.hxx" #include "util/StringBuffer.hxx" +#include "Log.hxx" +#include "LogBackend.hxx" #include #include @@ -20,13 +24,55 @@ #include #include -static constexpr auto usage_text = R"(Usage: run_storage COMMAND URI ... +static constexpr auto usage_text = R"(Usage: run_storage [OPTIONS] COMMAND URI ... + +Options: + --verbose Available commands: ls URI PATH stat URI PATH )"; +struct CommandLine { + bool verbose = false; + + const char *command; + + std::span args; +}; + +enum class Option { + VERBOSE, +}; + +static constexpr OptionDef option_defs[] = { + {"verbose", 'v', false, "Verbose logging"}, +}; + +static CommandLine +ParseCommandLine(int argc, char **argv) +{ + CommandLine c; + + OptionParser option_parser(option_defs, argc, argv); + while (auto o = option_parser.Next()) { + switch (static_cast