diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 69110b3aa4..fae2e0e71e 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -169,6 +169,7 @@ target_link_libraries(test-pthread LibThreading) target_link_libraries(timezone LibMain) target_link_libraries(top LibMain) target_link_libraries(touch LibMain) +target_link_libraries(tree LibMain) target_link_libraries(truncate LibMain) target_link_libraries(tt LibPthread) target_link_libraries(umount LibMain) diff --git a/Userland/Utilities/tree.cpp b/Userland/Utilities/tree.cpp index e31522b2a2..12f4ea8744 100644 --- a/Userland/Utilities/tree.cpp +++ b/Userland/Utilities/tree.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Stijn De Ridder + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -99,12 +102,9 @@ static void print_directory_tree(const String& root_path, int depth, const Strin } } -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath tty", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio rpath tty")); Vector directories; @@ -113,10 +113,10 @@ int main(int argc, char** argv) args_parser.add_option(flag_show_only_directories, "Show only directories", "only-directories", 'd'); args_parser.add_option(max_depth, "Maximum depth of the tree", "maximum-depth", 'L', "level"); args_parser.add_positional_argument(directories, "Directories to print", "directories", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (max_depth < 1) { - warnln("{}: Invalid level, must be greater than 0.", argv[0]); + warnln("{}: Invalid level, must be greater than 0.", arguments.argv[0]); return 1; }