// 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 "ConfigGlue.hxx" #include "tag/Tag.hxx" #include "storage/Registry.hxx" #include "storage/StorageInterface.hxx" #include "storage/FileInfo.hxx" #include "input/Init.hxx" #include "input/InputStream.hxx" #include "input/CondHandler.hxx" #include "fs/Path.hxx" #include "fs/NarrowPath.hxx" #include "event/Thread.hxx" #include "net/Init.hxx" #include "io/BufferedOutputStream.hxx" #include "io/FileDescriptor.hxx" #include "io/StdioOutputStream.hxx" #include "time/ChronoUtil.hxx" #include "time/ISO8601.hxx" #include "util/PrintException.hxx" #include "util/StringAPI.hxx" #include "util/StringBuffer.hxx" #include "Log.hxx" #include "LogBackend.hxx" #include "TagSave.hxx" #include "config.h" #ifdef ENABLE_ARCHIVE #include "archive/ArchiveList.hxx" #endif #include #include #include #include #include #include static constexpr auto usage_text = R"(Usage: run_storage [OPTIONS] COMMAND URI ... Options: --verbose Available commands: ls URI PATH stat URI PATH cat URI PATH )"; struct CommandLine { FromNarrowPath config_path; bool verbose = false; const char *command; std::span args; }; enum class Option { CONFIG, VERBOSE, }; static constexpr OptionDef option_defs[] = { {"config", 0, true, "Load a MPD configuration file"}, {"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