mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
echo: Port to LibMain :^)
This commit is contained in:
parent
d7336879d1
commit
98e65f71da
2 changed files with 6 additions and 6 deletions
|
@ -67,6 +67,7 @@ target_link_libraries(copy LibGUI LibMain)
|
||||||
target_link_libraries(diff LibDiff)
|
target_link_libraries(diff LibDiff)
|
||||||
target_link_libraries(disasm LibX86)
|
target_link_libraries(disasm LibX86)
|
||||||
target_link_libraries(dmesg LibMain)
|
target_link_libraries(dmesg LibMain)
|
||||||
|
target_link_libraries(echo LibMain)
|
||||||
target_link_libraries(expr LibRegex)
|
target_link_libraries(expr LibRegex)
|
||||||
target_link_libraries(fdtdump LibDeviceTree)
|
target_link_libraries(fdtdump LibDeviceTree)
|
||||||
target_link_libraries(file LibGfx LibIPC LibCompress)
|
target_link_libraries(file LibGfx LibIPC LibCompress)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <AK/CharacterTypes.h>
|
#include <AK/CharacterTypes.h>
|
||||||
#include <AK/GenericLexer.h>
|
#include <AK/GenericLexer.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -95,12 +97,9 @@ static String interpret_backslash_escapes(StringView string, bool& no_trailing_n
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<const char*> text;
|
Vector<const char*> text;
|
||||||
bool no_trailing_newline = false;
|
bool no_trailing_newline = false;
|
||||||
|
@ -111,7 +110,7 @@ int main(int argc, char** argv)
|
||||||
args_parser.add_option(should_interpret_backslash_escapes, "Interpret backslash escapes", nullptr, 'e');
|
args_parser.add_option(should_interpret_backslash_escapes, "Interpret backslash escapes", nullptr, 'e');
|
||||||
args_parser.add_positional_argument(text, "Text to print out", "text", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(text, "Text to print out", "text", Core::ArgsParser::Required::No);
|
||||||
args_parser.set_stop_on_first_non_option(true);
|
args_parser.set_stop_on_first_non_option(true);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
if (text.is_empty()) {
|
if (text.is_empty()) {
|
||||||
if (!no_trailing_newline)
|
if (!no_trailing_newline)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue