From e451ce816c6672044c5768484df633e0a726eebc Mon Sep 17 00:00:00 2001 From: Matus Ferech Date: Wed, 12 Aug 2020 23:23:45 +0200 Subject: [PATCH] HackStudio: Use Core::ArgsParser for path to workspace --- DevTools/HackStudio/main.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 515b2e7a9bc..580273a952a 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -39,6 +39,7 @@ #include "WidgetTool.h" #include "WidgetTreeModel.h" #include +#include #include #include #include @@ -205,12 +206,14 @@ int main(int argc, char** argv) if (!make_is_available()) GUI::MessageBox::show(g_window, "The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GUI::MessageBox::Type::Error); - String argument_absolute_path; - if (argc >= 2) - argument_absolute_path = Core::File::real_path_for(argv[1]); + const char* workspace_argument = nullptr; + Core::ArgsParser args_parser; + args_parser.add_positional_argument(workspace_argument, "Path to workspace", "workspace", Core::ArgsParser::Required::No); + args_parser.parse(argc, argv); - if (!argument_absolute_path.is_empty() && argument_absolute_path.ends_with(".hackstudio")) - open_project(argument_absolute_path); + auto workspace = Core::File::real_path_for(workspace_argument); + if (workspace.ends_with(".hackstudio")) + open_project(workspace); else open_project("/home/anon/Source/little/little.hackstudio"); @@ -718,8 +721,8 @@ int main(int argc, char** argv) g_open_file = open_file; - if (!argument_absolute_path.is_empty() && !argument_absolute_path.ends_with(".hackstudio")) - open_file(argument_absolute_path); + if (!workspace.is_empty() && !workspace.ends_with(".hackstudio")) + open_file(workspace); else open_file(g_project->default_file());