#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_system_program_info("rm"_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;
}