Luna/utils/ln.cpp
apio 140910763e
All checks were successful
Build and test / build (push) Successful in 1m56s
all: Reorder directory structure
Why are command-line utilities stored in "apps"?
And why are apps like "editor" or "terminal" top-level directories?
Command-line utilities now go in "utils".
GUI stuff now goes in "gui".
This includes: libui -> gui/libui, wind -> gui/wind, GUI apps -> gui/apps, editor&terminal -> gui/apps...
System services go in "system".
2024-07-21 13:24:46 +02:00

30 lines
794 B
C++

#include <os/ArgumentParser.h>
#include <stdio.h>
#include <unistd.h>
Result<int> luna_main(int argc, char** argv)
{
StringView target;
StringView linkpath;
bool create_symlink { false };
os::ArgumentParser parser;
parser.add_description("Create links between files.");
parser.add_system_program_info("ln"_sv);
parser.add_positional_argument(target, "target", true);
parser.add_positional_argument(linkpath, "linkpath", true);
parser.add_switch_argument(create_symlink, 's', "symbolic"_sv, "create symlinks instead of hard links"_sv);
parser.parse(argc, argv);
auto link_function = create_symlink ? symlink : link;
if (link_function(target.chars(), linkpath.chars()) < 0)
{
perror("ln");
return 1;
}
return 0;
}