summaryrefslogtreecommitdiff
path: root/Userland/Utilities/ls.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-02 22:42:10 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-04 14:24:04 +0100
commit0de575ec11cd059663b10e11eca0b4282e0ca0de (patch)
tree77b341aa852aa6aa3bdd1a184063e6dedae81a5b /Userland/Utilities/ls.cpp
parent1640445cb2f5027eebbce90faf5273cff85ed844 (diff)
downloadserenity-0de575ec11cd059663b10e11eca0b4282e0ca0de.zip
ls: Port to LibMain :^)
Diffstat (limited to 'Userland/Utilities/ls.cpp')
-rw-r--r--Userland/Utilities/ls.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp
index 39614ed889..51f90d905d 100644
--- a/Userland/Utilities/ls.cpp
+++ b/Userland/Utilities/ls.cpp
@@ -17,6 +17,8 @@
#include <LibCore/DateTime.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
+#include <LibCore/System.h>
+#include <LibMain/Main.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@@ -71,12 +73,9 @@ static HashMap<gid_t, String> groups;
static bool is_a_tty = false;
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio rpath tty", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio rpath tty"));
struct winsize ws;
int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
@@ -118,7 +117,7 @@ int main(int argc, char** argv)
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
args_parser.add_option(flag_recursive, "List subdirectories recursively", "recursive", 'R');
args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No);
- args_parser.parse(argc, argv);
+ args_parser.parse(arguments);
if (flag_show_almost_all_dotfiles)
flag_show_dotfiles = true;