22 lines
648 B
C++
22 lines
648 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_description("Remove a path from the file system."_sv);
|
|
parser.add_positional_argument(path, "path"_sv, true);
|
|
parser.add_switch_argument(recursive, 'r', "recursive"_sv,
|
|
"remove a directory recursively (by default, rm removes only empty directories)"_sv);
|
|
parser.parse(argc, argv);
|
|
|
|
if (!recursive) TRY(os::FileSystem::remove(path));
|
|
else
|
|
TRY(os::FileSystem::remove_tree(path));
|
|
|
|
return 0;
|
|
}
|