From cfecfbb2143ecf107020c8dc499645a58a63071a Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Mon, 22 Nov 2021 19:25:30 +0000 Subject: [PATCH] js: Port to LibMain :^) This wasn't particularly difficult, and there's not much use for the nicer interface yet either. While unveil() is of limited use in js(1) as it should be able to open arbitrary files, I feel like we should be able to add a pledge() call. --- Meta/Lagom/CMakeLists.txt | 2 +- Userland/Utilities/CMakeLists.txt | 2 +- Userland/Utilities/js.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 89d8597cdf..e7dcede738 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -455,7 +455,7 @@ if (BUILD_LAGOM) add_executable(js_lagom ../../Userland/Utilities/js.cpp) set_target_properties(js_lagom PROPERTIES OUTPUT_NAME js) - target_link_libraries(js_lagom LagomJS LagomLine Threads::Threads) + target_link_libraries(js_lagom LagomJS LagomLine LagomMain Threads::Threads) add_executable(markdown-check_lagom ../../Userland/Utilities/markdown-check.cpp) set_target_properties(markdown-check_lagom PROPERTIES OUTPUT_NAME markdown-check) diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 6849c9ff12..0d396932be 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -70,7 +70,7 @@ target_link_libraries(grep LibRegex) target_link_libraries(gunzip LibCompress) target_link_libraries(gzip LibCompress) target_link_libraries(id LibMain) -target_link_libraries(js LibJS LibLine) +target_link_libraries(js LibJS LibLine LibMain) target_link_libraries(keymap LibKeyboard) target_link_libraries(lspci LibPCIDB) target_link_libraries(lsusb LibUSBDB) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 29d57f2cfd..9844c2c454 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -1102,7 +1103,7 @@ public: } }; -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { bool gc_on_every_allocation = false; bool disable_syntax_highlight = false; @@ -1123,7 +1124,7 @@ int main(int argc, char** argv) #endif args_parser.add_option(disable_syntax_highlight, "Disable live syntax highlighting", "no-syntax-highlight", 's'); args_parser.add_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments.argc, arguments.argv); bool syntax_highlight = !disable_syntax_highlight;