2024-05-27 11:44:45 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Common/TerminalSize.h>
|
|
|
|
#include "DisksApp.h"
|
|
|
|
#include "ICommand.h"
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class CommandSwitchDisk final : public ICommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit CommandSwitchDisk() : ICommand()
|
|
|
|
{
|
|
|
|
command_name = "switch-disk";
|
2024-05-30 14:07:25 +00:00
|
|
|
description = "Switch disk (makes sense only in interactive mode)";
|
2024-05-27 11:44:45 +00:00
|
|
|
options_description.add_options()("disk", po::value<String>(), "the disk to switch to (mandatory, positional)")(
|
|
|
|
"path", po::value<String>(), "the path to switch on the disk");
|
|
|
|
positional_options_description.add("disk", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void executeImpl(const CommandLineOptions & options, DisksClient & client) override
|
|
|
|
{
|
|
|
|
String disk = getValueFromCommandLineOptions<String>(options, "disk");
|
|
|
|
std::optional<String> path = getValueFromCommandLineOptionsWithOptional<String>(options, "path");
|
|
|
|
|
2024-05-28 13:17:49 +00:00
|
|
|
client.switchToDisk(disk, path);
|
2024-05-27 11:44:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
CommandPtr makeCommandSwitchDisk()
|
|
|
|
{
|
2024-07-01 17:35:07 +00:00
|
|
|
return std::make_shared<DB::CommandSwitchDisk>();
|
2024-05-27 11:44:45 +00:00
|
|
|
}
|
|
|
|
}
|