apps: Add ln
This commit is contained in:
parent
7a8ef52408
commit
4ec1af5e51
@ -28,3 +28,4 @@ luna_app(mount.cpp mount)
|
||||
luna_app(umount.cpp umount)
|
||||
luna_app(ps.cpp ps)
|
||||
luna_app(time.cpp time)
|
||||
luna_app(ln.cpp ln)
|
||||
|
24
apps/ln.cpp
Normal file
24
apps/ln.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user