head: Port to LibMain

This commit is contained in:
Lucas CHOLLET 2022-01-14 10:25:11 +01:00 committed by Idan Horowitz
parent 5ac52d0e4c
commit 02cb34a48a
Notes: sideshowbarker 2024-07-17 20:54:20 +09:00
2 changed files with 6 additions and 6 deletions

View file

@ -105,6 +105,7 @@ target_link_libraries(gron LibMain)
target_link_libraries(groups LibMain)
target_link_libraries(gunzip LibCompress LibMain)
target_link_libraries(gzip LibCompress LibMain)
target_link_libraries(head LibMain)
target_link_libraries(id LibMain)
target_link_libraries(ini LibMain)
target_link_libraries(jp LibMain)

View file

@ -6,6 +6,8 @@
#include <AK/StdLibExtras.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -14,12 +16,9 @@
int head(const String& filename, bool print_filename, ssize_t line_count, ssize_t byte_count);
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments args)
{
if (pledge("stdio rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio rpath", nullptr));
int line_count = -1;
int byte_count = -1;
@ -34,7 +33,7 @@ int main(int argc, char** argv)
args_parser.add_option(never_print_filenames, "Never print filenames", "quiet", 'q');
args_parser.add_option(always_print_filenames, "Always print filenames", "verbose", 'v');
args_parser.add_positional_argument(files, "File to process", "file", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
args_parser.parse(args);
if (line_count == -1 && byte_count == -1) {
line_count = 10;