diff options
author | Linus Groh <mail@linusgroh.de> | 2020-08-05 16:39:55 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-05 16:54:23 +0200 |
commit | a8d7cd5a156b87fae5322817642b3ff939fd48c1 (patch) | |
tree | c72527c662fc1e726fd16d614bd583b89cd4fa93 | |
parent | 0d493c187952ddbd03141b513689ea309b73e65d (diff) | |
download | serenity-a8d7cd5a156b87fae5322817642b3ff939fd48c1.zip |
HackStudio: Open project or file from argv[1] if given
When HackStudio is invoked with one or more arguments it will attempt to
treat the first argument as a project or source file and open it
accordingly.
-rw-r--r-- | DevTools/HackStudio/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 11888d7423..4177cd3adb 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -189,7 +189,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); - open_project("/home/anon/little/little.hackstudio"); + String argument_absolute_path; + if (argc >= 2) + argument_absolute_path = Core::File::real_path_for(argv[1]); + + if (!argument_absolute_path.is_empty() && argument_absolute_path.ends_with(".hackstudio")) + open_project(argument_absolute_path); + else + open_project("/home/anon/little/little.hackstudio"); auto& toolbar_container = widget.add<GUI::ToolBarContainer>(); auto& toolbar = toolbar_container.add<GUI::ToolBar>(); @@ -684,7 +691,10 @@ int main(int argc, char** argv) g_open_file = open_file; - open_file(g_project->default_file()); + if (!argument_absolute_path.is_empty() && !argument_absolute_path.ends_with(".hackstudio")) + open_file(argument_absolute_path); + else + open_file(g_project->default_file()); update_actions(); return app->exec(); |