mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
cat: Port to LibMain :^)
This commit is contained in:
parent
7b2bd79855
commit
507de4bc1d
2 changed files with 7 additions and 10 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
@ -13,19 +15,16 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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", nullptr));
|
||||
|
||||
Vector<String> paths;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.set_general_help("Concatenate files or pipes to stdout.");
|
||||
args_parser.add_positional_argument(paths, "File path", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
Vector<int> fds;
|
||||
if (!paths.is_empty()) {
|
||||
|
@ -43,10 +42,7 @@ int main(int argc, char** argv)
|
|||
fds.append(0);
|
||||
}
|
||||
|
||||
if (pledge("stdio", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio", nullptr));
|
||||
|
||||
for (auto& fd : fds) {
|
||||
for (;;) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue