8namespace fs = std::filesystem;
18 if (base_path.filename() !=
"arkanjo") {
19 throw CLIError(
"Invalid cache directory.");
24 cache_dir = fs::weakly_canonical(cache_dir);
26 if (fs::exists(cache_dir)) {
28 for (
const auto& entry : fs::directory_iterator(base_path))
29 fs::remove_all(entry.path());
31 std::cout <<
"Successfully cleaned all cache directories in: " << cache_dir.string() <<
"\n";
33 fs::remove_all(cache_dir);
35 std::cout <<
"Successfully cleaned cache directory: " << cache_dir.string() <<
"\n";
38 else std::cout <<
"Cache directory does not exist, nothing to clean.\n";
40 }
catch (
const std::exception& e) {
41 throw CLIError(
"Error while cleaning cache: " + std::string(e.what()));
Base class for CLI-related errors.
const CliOption * options() const final
static Config & config()
Gets the singleton configuration instance.
bool run(const ParsedOptions &options) override
Executes the main logic of the command.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
Configuration management interface.
Remove cached application data.
std::filesystem::path base_path
Default base path for temporary files.
std::filesystem::path name_container
Name of the cache container.