1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add --scene command line argument

This commit is contained in:
kobewi
2025-04-12 09:15:10 +02:00
parent 215acd52e8
commit 47568a4654
2 changed files with 11 additions and 2 deletions

View File

@@ -513,7 +513,7 @@ void Main::print_help(const char *p_binary) {
print_help_copyright("(c) 2014-present Godot Engine contributors. (c) 2007-present Juan Linietsky, Ariel Manzur.");
print_help_title("Usage");
OS::get_singleton()->print(" %s \u001b[96m[options] [path to scene or \"project.godot\" file]\u001b[0m\n", p_binary);
OS::get_singleton()->print(" %s \u001b[96m[options] [path to \"project.godot\" file]\u001b[0m\n", p_binary);
#if defined(TOOLS_ENABLED)
print_help_title("Option legend (this build = editor)");
@@ -554,6 +554,7 @@ void Main::print_help(const char *p_binary) {
print_help_option("--quit-after <int>", "Quit after the given number of iterations. Set to 0 to disable.\n");
print_help_option("-l, --language <locale>", "Use a specific locale (<locale> being a two-letter code).\n");
print_help_option("--path <directory>", "Path to a project (<directory> must contain a \"project.godot\" file).\n");
print_help_option("--scene <path>", "Path or UID of a scene in the project that should be started.\n");
print_help_option("-u, --upwards", "Scan folders upwards for project.godot file.\n");
print_help_option("--main-pack <file>", "Path to a pack (.pck) file to load.\n");
#ifdef DISABLE_DEPRECATED
@@ -3846,7 +3847,14 @@ int Main::start() {
} else if (E->get() == "--install-android-build-template") {
install_android_build_template = true;
#endif // TOOLS_ENABLED
} else if (E->get().length() && E->get()[0] != '-' && positional_arg.is_empty()) {
} else if (E->get() == "--scene") {
E = E->next();
if (E) {
game_path = E->get();
} else {
ERR_FAIL_V_MSG(EXIT_FAILURE, "Missing scene path, aborting.");
}
} else if (E->get().length() && E->get()[0] != '-' && positional_arg.is_empty() && game_path.is_empty()) {
positional_arg = E->get();
if (E->get().ends_with(".scn") ||