Luna/apps/ln.cpp

25 lines
564 B
C++
Raw Normal View History

2023-05-20 19:48:28 +00:00
#include <os/ArgumentParser.h>
#include <stdio.h>
#include <unistd.h>
Result<int> luna_main(int argc, char** argv)
{
StringView target;
StringView link;
os::ArgumentParser parser;
parser.add_description("Create symbolic links.");
parser.add_system_program_info("ln"_sv);
parser.add_positional_argument(target, "target", true);
parser.add_positional_argument(link, "linkpath", true);
parser.parse(argc, argv);
if (symlink(target.chars(), link.chars()) < 0)
{
perror("ln");
return 1;
}
return 0;
}