ClickHouse/programs/disks/CommandRemove.cpp

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

32 lines
899 B
C++
Raw Normal View History

2022-07-20 20:30:16 +00:00
#include <Interpreters/Context.h>
2024-05-27 11:44:45 +00:00
#include "ICommand.h"
namespace DB
{
class CommandRemove final : public ICommand
{
public:
CommandRemove()
{
command_name = "remove";
2024-05-29 13:57:29 +00:00
description = "Remove file or directory with all children. Throws exception if file doesn't exists";
2024-05-27 11:44:45 +00:00
options_description.add_options()("path", po::value<String>(), "path from which we copy (mandatory, positional)");
positional_options_description.add("path", 1);
}
2024-05-27 11:44:45 +00:00
void executeImpl(const CommandLineOptions & options, DisksClient & client) override
{
auto disk = getDiskWithPath(client, options, "disk");
2024-05-27 11:44:45 +00:00
const String & path = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path"));
disk.getDisk()->removeRecursive(path);
}
};
2024-05-27 11:44:45 +00:00
CommandPtr makeCommandRemove()
{
return std::make_unique<DB::CommandRemove>();
}
2024-05-27 11:44:45 +00:00
}