2022-04-08 07:52:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Loggers/Loggers.h>
|
|
|
|
|
|
|
|
#include <Interpreters/Context.h>
|
2022-12-08 17:20:54 +00:00
|
|
|
#include <Poco/Util/Application.h>
|
|
|
|
|
|
|
|
#include <boost/program_options.hpp>
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-12-08 17:20:54 +00:00
|
|
|
class ICommand;
|
2022-04-08 07:52:16 +00:00
|
|
|
using CommandPtr = std::unique_ptr<ICommand>;
|
|
|
|
|
2022-12-08 17:20:54 +00:00
|
|
|
namespace po = boost::program_options;
|
|
|
|
using ProgramOptionsDescription = boost::program_options::options_description;
|
|
|
|
using CommandLineOptions = boost::program_options::variables_map;
|
|
|
|
|
2022-04-08 07:52:16 +00:00
|
|
|
class DisksApp : public Poco::Util::Application, public Loggers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DisksApp() = default;
|
2024-02-14 02:01:03 +00:00
|
|
|
~DisksApp() override;
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
void init(std::vector<String> & common_arguments);
|
|
|
|
|
|
|
|
int main(const std::vector<String> & args) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static String getDefaultConfigFileName();
|
|
|
|
|
|
|
|
void addOptions(
|
2022-06-21 14:40:22 +00:00
|
|
|
ProgramOptionsDescription & options_description,
|
2022-04-08 07:52:16 +00:00
|
|
|
boost::program_options::positional_options_description & positional_options_description);
|
|
|
|
void processOptions();
|
|
|
|
|
2022-06-21 14:40:22 +00:00
|
|
|
void printHelpMessage(ProgramOptionsDescription & command_option_description);
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
size_t findCommandPos(std::vector<String> & common_arguments);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parseAndCheckOptions(
|
2022-06-21 14:40:22 +00:00
|
|
|
ProgramOptionsDescription & options_description,
|
2022-04-08 07:52:16 +00:00
|
|
|
boost::program_options::positional_options_description & positional_options_description,
|
|
|
|
std::vector<String> & arguments);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ContextMutablePtr global_context;
|
|
|
|
SharedContextHolder shared_context;
|
|
|
|
|
|
|
|
String command_name;
|
2022-06-16 17:38:33 +00:00
|
|
|
std::vector<String> command_arguments;
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
std::unordered_set<String> supported_commands;
|
|
|
|
std::unordered_map<String, CommandPtr> command_descriptions;
|
|
|
|
|
|
|
|
po::variables_map options;
|
|
|
|
};
|
2024-02-14 02:31:31 +00:00
|
|
|
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|