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