2020-06-10 18:25:41 +02:00
|
|
|
extends Node2D
|
|
|
|
|
2020-09-01 15:14:01 +02:00
|
|
|
var thread
|
|
|
|
|
2020-09-01 14:03:18 +02:00
|
|
|
func send_command(command):
|
2020-09-01 15:14:01 +02:00
|
|
|
thread = Thread.new()
|
|
|
|
thread.start(self, "run_command_in_a_thread", command)
|
|
|
|
|
|
|
|
func run_command_in_a_thread(command):
|
2020-09-01 14:03:18 +02:00
|
|
|
var cwd = run("pwd")
|
2020-08-24 16:48:30 +02:00
|
|
|
var output = []
|
2020-09-01 14:03:18 +02:00
|
|
|
|
|
|
|
var hacky_command = command
|
|
|
|
hacky_command = "cd /tmp/githydragit;"+hacky_command
|
|
|
|
hacky_command = "export EDITOR=fake-editor;"+hacky_command
|
|
|
|
hacky_command = "export PATH=\"$PATH\":"+cwd+"/scripts;"+hacky_command
|
|
|
|
OS.execute("/bin/sh", ["-c", hacky_command], true, output, true)
|
|
|
|
|
2020-08-24 16:48:30 +02:00
|
|
|
$Input.text = ""
|
2020-09-01 14:03:18 +02:00
|
|
|
$Output.text = $Output.text + "$ " + command + "\n" + output[0]
|
2020-08-24 16:48:30 +02:00
|
|
|
$Output.scroll_vertical = 999999
|
2020-09-01 14:03:18 +02:00
|
|
|
|
|
|
|
func run(command):
|
|
|
|
var output = []
|
|
|
|
OS.execute(command, [], true, output, true)
|
|
|
|
# Remove trailing newline.
|
|
|
|
return output[0].substr(0,len(output[0])-1)
|