Skip to content

Commit 9d01793

Browse files
committed
Add --import command-line flag
1 parent a7b8602 commit 9d01793

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

editor/editor_file_system.h

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class EditorFileSystem : public Node {
304304
EditorFileSystemDirectory *get_filesystem();
305305
bool is_scanning() const;
306306
bool is_importing() const { return importing; }
307+
bool doing_first_scan() const { return first_scan; }
307308
float get_scanning_progress() const;
308309
void scan();
309310
void scan_changes();

main/main.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#include "editor/debugger/editor_debugger_node.h"
9393
#include "editor/doc_data_class_path.gen.h"
9494
#include "editor/doc_tools.h"
95+
#include "editor/editor_file_system.h"
9596
#include "editor/editor_help.h"
9697
#include "editor/editor_node.h"
9798
#include "editor/editor_paths.h"
@@ -184,6 +185,7 @@ static OS::ProcessID editor_pid = 0;
184185
static bool found_project = false;
185186
static bool auto_build_solutions = false;
186187
static String debug_server_uri;
188+
static bool wait_for_import = false;
187189
#ifndef DISABLE_DEPRECATED
188190
static int converter_max_kb_file = 4 * 1024; // 4MB
189191
static int converter_max_line_length = 100000;
@@ -617,6 +619,7 @@ void Main::print_help(const char *p_binary) {
617619
print_help_option("--main-loop <main_loop_name>", "Run a MainLoop specified by its global class name.\n");
618620
print_help_option("--check-only", "Only parse for errors and quit (use with --script).\n");
619621
#ifdef TOOLS_ENABLED
622+
print_help_option("--import", "Starts the editor, waits for any resources to be imported, and then quits.\n", CLI_OPTION_AVAILABILITY_EDITOR);
620623
print_help_option("--export-release <preset> <path>", "Export the project in release mode using the given preset and output path. The preset name should match one defined in \"export_presets.cfg\".\n", CLI_OPTION_AVAILABILITY_EDITOR);
621624
print_help_option("", "<path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. \"builds/game.exe\").\n");
622625
print_help_option("", "The target directory must exist.\n");
@@ -1420,12 +1423,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
14201423
OS::get_singleton()->print("Missing file to load argument after --validate-extension-api, aborting.");
14211424
goto error;
14221425
}
1423-
1426+
} else if (I->get() == "--import") {
1427+
editor = true;
1428+
cmdline_tool = true;
1429+
wait_for_import = true;
1430+
quit_after = 1;
14241431
} else if (I->get() == "--export-release" || I->get() == "--export-debug" ||
14251432
I->get() == "--export-pack") { // Export project
14261433
// Actually handling is done in start().
14271434
editor = true;
14281435
cmdline_tool = true;
1436+
wait_for_import = true;
14291437
main_args.push_back(I->get());
14301438
#ifndef DISABLE_DEPRECATED
14311439
} else if (I->get() == "--export") { // For users used to 3.x syntax.
@@ -4084,6 +4092,12 @@ bool Main::iteration() {
40844092
exit = true;
40854093
}
40864094

4095+
#ifdef TOOLS_ENABLED
4096+
if (wait_for_import && EditorFileSystem::get_singleton()->doing_first_scan()) {
4097+
exit = false;
4098+
}
4099+
#endif
4100+
40874101
if (fixed_fps != -1) {
40884102
return exit;
40894103
}

0 commit comments

Comments
 (0)