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

Expose OS.read_string_from_stdin() to the scripting API

This can be used in scripts to read user input in a blocking manner.

This also removes the unused `block` argument, which is always `true`.
This commit is contained in:
Hugo Locurcio
2022-12-21 00:30:55 +01:00
parent 7d6db300d2
commit badcfa2523
10 changed files with 26 additions and 21 deletions

View File

@@ -520,6 +520,10 @@ Error _OS::shell_open(String p_uri) {
return OS::get_singleton()->shell_open(p_uri);
};
String _OS::read_string_from_stdin() {
return OS::get_singleton()->get_stdin_string();
}
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr, bool p_open_console) {
OS::ProcessID pid = -2;
int exitcode = 0;
@@ -1415,6 +1419,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_processor_name"), &_OS::get_processor_name);
ClassDB::bind_method(D_METHOD("get_executable_path"), &_OS::get_executable_path);
ClassDB::bind_method(D_METHOD("read_string_from_stdin"), &_OS::read_string_from_stdin);
ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output", "read_stderr", "open_console"), &_OS::execute, DEFVAL(true), DEFVAL(Array()), DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill);
ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open);