2022-07-20 20:30:16 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2024-05-27 11:44:45 +00:00
|
|
|
#include "ICommand.h"
|
2022-04-08 07:52:16 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-12-08 17:20:54 +00:00
|
|
|
class CommandRemove final : public ICommand
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
|
|
|
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);
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|
|
|
|
|
2024-05-27 11:44:45 +00:00
|
|
|
void executeImpl(const CommandLineOptions & options, DisksClient & client) override
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
2024-06-14 13:02:41 +00:00
|
|
|
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);
|
2022-04-08 07:52:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-05-27 11:44:45 +00:00
|
|
|
CommandPtr makeCommandRemove()
|
2022-04-08 07:52:16 +00:00
|
|
|
{
|
|
|
|
return std::make_unique<DB::CommandRemove>();
|
|
|
|
}
|
2024-05-27 11:44:45 +00:00
|
|
|
|
|
|
|
}
|