Luna/apps/rm.cpp
apio d56e8baca5
All checks were successful
continuous-integration/drone/push Build is passing
libos+rm: Add recursive removal of directories
2023-04-19 18:20:44 +02:00

20 lines
462 B
C++

#include <os/ArgumentParser.h>
#include <os/FileSystem.h>
Result<int> luna_main(int argc, char** argv)
{
StringView path;
bool recursive;
os::ArgumentParser parser;
parser.add_positional_argument(path, "path"_sv, true);
parser.add_switch_argument(recursive, 'r', "recursive"_sv);
parser.parse(argc, argv);
if (!recursive) TRY(os::FileSystem::remove(path));
else
TRY(os::FileSystem::remove_tree(path));
return 0;
}