mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
wc: Port to LibMain
This commit is contained in:
parent
fc78bbe78c
commit
7f9bd34d07
2 changed files with 6 additions and 10 deletions
|
@ -162,6 +162,7 @@ target_link_libraries(cpp-parser LibCpp LibGUI)
|
|||
target_link_libraries(cpp-preprocessor LibCpp LibGUI)
|
||||
target_link_libraries(w LibMain)
|
||||
target_link_libraries(wasm LibWasm LibLine)
|
||||
target_link_libraries(wc LibMain)
|
||||
target_link_libraries(which LibMain)
|
||||
target_link_libraries(whoami LibMain)
|
||||
target_link_libraries(watch LibMain)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -85,12 +86,9 @@ static Count get_total_count(const Vector<Count>& counts)
|
|||
return total_count;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
|
||||
Vector<const char*> file_specifiers;
|
||||
|
||||
|
@ -99,7 +97,7 @@ int main(int argc, char** argv)
|
|||
args_parser.add_option(g_output_byte, "Output byte count", "bytes", 'c');
|
||||
args_parser.add_option(g_output_word, "Output word count", "words", 'w');
|
||||
args_parser.add_positional_argument(file_specifiers, "File to process", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (!g_output_line && !g_output_byte && !g_output_word)
|
||||
g_output_line = g_output_byte = g_output_word = true;
|
||||
|
@ -108,10 +106,7 @@ int main(int argc, char** argv)
|
|||
for (const auto& file_specifier : file_specifiers)
|
||||
counts.append(get_count(file_specifier));
|
||||
|
||||
if (pledge("stdio", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
if (file_specifiers.is_empty())
|
||||
counts.append(get_count("-"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue