ClickHouse/programs/disks/CommandListDisks.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1003 B
C++
Raw Permalink Normal View History

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"
namespace DB
{
class CommandListDisks final : public ICommand
{
public:
2024-05-27 11:44:45 +00:00
explicit CommandListDisks() : ICommand()
{
command_name = "list-disks";
2024-05-27 11:44:45 +00:00
description = "Lists all available disks";
}
2024-05-27 11:44:45 +00:00
void executeImpl(const CommandLineOptions &, DisksClient & client) override
{
2024-05-27 11:44:45 +00:00
std::vector<String> sorted_and_selected{};
for (const auto & disk_name : client.getAllDiskNames())
{
2024-05-27 11:44:45 +00:00
sorted_and_selected.push_back(disk_name + ":" + client.getDiskWithPath(disk_name).getAbsolutePath(""));
}
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
}
}
2024-05-27 11:44:45 +00:00
private:
};
2024-05-27 11:44:45 +00:00
CommandPtr makeCommandListDisks()
{
2024-05-27 11:44:45 +00:00
return std::make_shared<DB::CommandListDisks>();
}
}