2024-05-27 11:44:45 +00:00
|
|
|
#include <algorithm>
|
2022-07-20 20:30:16 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2024-05-27 11:44:45 +00:00
|
|
|
#include <Common/TerminalSize.h>
|
|
|
|
#include "DisksClient.h"
|
|
|
|
#include "ICommand.h"
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-12-08 17:20:54 +00:00
|
|
|
class CommandListDisks final : public ICommand
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2024-05-27 11:44:45 +00:00
|
|
|
explicit CommandListDisks() : ICommand()
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
|
|
|
command_name = "list-disks";
|
2024-05-27 11:44:45 +00:00
|
|
|
description = "Lists all available disks";
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|
|
|
|
|
2024-05-27 11:44:45 +00:00
|
|
|
void executeImpl(const CommandLineOptions &, DisksClient & client) override
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
2024-05-27 11:44:45 +00:00
|
|
|
std::vector<String> sorted_and_selected{};
|
|
|
|
for (const auto & disk_name : client.getAllDiskNames())
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
2024-05-27 11:44:45 +00:00
|
|
|
sorted_and_selected.push_back(disk_name + ":" + client.getDiskWithPath(disk_name).getAbsolutePath(""));
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|
2024-05-27 11:44:45 +00:00
|
|
|
std::sort(sorted_and_selected.begin(), sorted_and_selected.end());
|
|
|
|
for (const auto & disk_name : sorted_and_selected)
|
2023-11-30 03:09:55 +00:00
|
|
|
{
|
2024-05-27 11:44:45 +00:00
|
|
|
std::cout << disk_name << "\n";
|
2023-11-30 03:09:55 +00:00
|
|
|
}
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|
2024-05-27 11:44:45 +00:00
|
|
|
|
|
|
|
private:
|
2022-04-08 07:52:16 +00:00
|
|
|
};
|
|
|
|
|
2024-05-27 11:44:45 +00:00
|
|
|
CommandPtr makeCommandListDisks()
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
2024-05-27 11:44:45 +00:00
|
|
|
return std::make_shared<DB::CommandListDisks>();
|
|
|
|
}
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|