mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:07:46 +00:00
head: Port to LibMain
This commit is contained in:
parent
5ac52d0e4c
commit
02cb34a48a
2 changed files with 6 additions and 6 deletions
|
@ -105,6 +105,7 @@ target_link_libraries(gron LibMain)
|
||||||
target_link_libraries(groups LibMain)
|
target_link_libraries(groups LibMain)
|
||||||
target_link_libraries(gunzip LibCompress LibMain)
|
target_link_libraries(gunzip LibCompress LibMain)
|
||||||
target_link_libraries(gzip LibCompress LibMain)
|
target_link_libraries(gzip LibCompress LibMain)
|
||||||
|
target_link_libraries(head LibMain)
|
||||||
target_link_libraries(id LibMain)
|
target_link_libraries(id LibMain)
|
||||||
target_link_libraries(ini LibMain)
|
target_link_libraries(ini LibMain)
|
||||||
target_link_libraries(jp LibMain)
|
target_link_libraries(jp LibMain)
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.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 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) {
|
TRY(Core::System::pledge("stdio rpath", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int line_count = -1;
|
int line_count = -1;
|
||||||
int byte_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(never_print_filenames, "Never print filenames", "quiet", 'q');
|
||||||
args_parser.add_option(always_print_filenames, "Always print filenames", "verbose", 'v');
|
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.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) {
|
if (line_count == -1 && byte_count == -1) {
|
||||||
line_count = 10;
|
line_count = 10;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue