mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#include <Interpreters/Context.h>
|
|
#include "ICommand.h"
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int BAD_ARGUMENTS;
|
|
}
|
|
|
|
class CommandRemove final : public ICommand
|
|
{
|
|
public:
|
|
CommandRemove()
|
|
{
|
|
command_name = "remove";
|
|
description = "Remove file or directory with all children. Throws exception if file doesn't exists.\nPath should be in format './' "
|
|
"or './path' or 'path'";
|
|
options_description.add_options()("path", po::value<String>(), "path from which we copy (mandatory, positional)");
|
|
positional_options_description.add("path", 1);
|
|
}
|
|
|
|
void executeImpl(const CommandLineOptions & options, DisksClient & client) override
|
|
{
|
|
auto disk = client.getCurrentDiskWithPath();
|
|
const String & path = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path"));
|
|
disk.getDisk()->removeRecursive(path);
|
|
}
|
|
};
|
|
|
|
CommandPtr makeCommandRemove()
|
|
{
|
|
return std::make_unique<DB::CommandRemove>();
|
|
}
|
|
|
|
}
|