nl: Port to LibMain

This commit is contained in:
Kenneth Myhra 2022-01-30 11:17:58 +01:00 committed by Andreas Kling
parent cf207ad938
commit a64b44377d
2 changed files with 4 additions and 2 deletions

View file

@ -138,6 +138,7 @@ target_link_libraries(mv LibMain)
target_link_libraries(mount LibMain) target_link_libraries(mount LibMain)
target_link_libraries(nc LibMain) target_link_libraries(nc LibMain)
target_link_libraries(netstat LibMain) target_link_libraries(netstat LibMain)
target_link_libraries(nl LibMain)
target_link_libraries(notify LibGUI) target_link_libraries(notify LibGUI)
target_link_libraries(nproc LibMain) target_link_libraries(nproc LibMain)
target_link_libraries(open LibDesktop) target_link_libraries(open LibDesktop)

View file

@ -7,6 +7,7 @@
#include <AK/String.h> #include <AK/String.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibMain/Main.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -17,7 +18,7 @@ enum NumberStyle {
NumberNoLines, NumberNoLines,
}; };
int main(int argc, char** argv) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
NumberStyle number_style = NumberNonEmptyLines; NumberStyle number_style = NumberNonEmptyLines;
int increment = 1; int increment = 1;
@ -54,7 +55,7 @@ int main(int argc, char** argv)
args_parser.add_option(start_number, "Initial line number", "startnum", 'v', "number"); args_parser.add_option(start_number, "Initial line number", "startnum", 'v', "number");
args_parser.add_option(number_width, "Number width", "width", 'w', "number"); args_parser.add_option(number_width, "Number width", "width", 'w', "number");
args_parser.add_positional_argument(files, "Files to process", "file", Core::ArgsParser::Required::No); args_parser.add_positional_argument(files, "Files to process", "file", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv); args_parser.parse(arguments);
Vector<FILE*> file_pointers; Vector<FILE*> file_pointers;
if (!files.is_empty()) { if (!files.is_empty()) {