mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-20 20:33:11 +01:00
Run commands in the terminal using /bin/sh
And some hacks that set the EDITOR and the PATH.
This commit is contained in:
parent
f3c311be58
commit
80cbff92a1
3 changed files with 27 additions and 21 deletions
13
main.gd
13
main.gd
|
@ -105,13 +105,16 @@ func git(args, splitlines = false):
|
|||
var a = args.split(" ")
|
||||
#print ("Running: ", a)
|
||||
a.insert(0, "-C")
|
||||
a.insert(1, "/home/seb/tmp/godotgit")
|
||||
a.insert(1, "/tmp/githydragit")
|
||||
OS.execute("git", a, true, output, true)
|
||||
var o = output[0]
|
||||
|
||||
if splitlines:
|
||||
o = o.split("\n")
|
||||
# Remove last empty line.
|
||||
o.remove(len(o)-1)
|
||||
else:
|
||||
# Remove trailing newline.
|
||||
o = o.substr(0,len(o)-1)
|
||||
return o
|
||||
|
||||
|
@ -124,14 +127,6 @@ func update_head():
|
|||
n.position = Vector2(rand_range(0, viewport_size.x), rand_range(0, viewport_size.y))
|
||||
objects["HEAD"] = n
|
||||
add_child(n)
|
||||
|
||||
n = node.instance()
|
||||
n.id = "refs/heads/master"
|
||||
n.type = "ref"
|
||||
n.content = ""
|
||||
n.position = Vector2(rand_range(0, viewport_size.x), rand_range(0, viewport_size.y))
|
||||
objects[n.id] = n
|
||||
add_child(n)
|
||||
var n = objects["HEAD"]
|
||||
n.children = {symref_target("HEAD"): ""}
|
||||
|
||||
|
|
6
scripts/fake-editor
Executable file
6
scripts/fake-editor
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo Hi, I am commit-hook
|
||||
echo $*
|
||||
zenity --question
|
||||
echo Goodbye
|
29
terminal.gd
29
terminal.gd
|
@ -1,17 +1,22 @@
|
|||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
func send_command(new_text):
|
||||
var parts = new_text.split(" ")
|
||||
var cmd = parts[0]
|
||||
var args = parts
|
||||
args.remove(0)
|
||||
func send_command(command):
|
||||
var cwd = run("pwd")
|
||||
|
||||
var output = []
|
||||
OS.execute(cmd, args, true, output, true)
|
||||
|
||||
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)
|
||||
|
||||
$Input.text = ""
|
||||
$Output.text = $Output.text + "$ " + new_text + "\n" + output[0]
|
||||
$Output.text = $Output.text + "$ " + command + "\n" + output[0]
|
||||
$Output.scroll_vertical = 999999
|
||||
|
||||
func run(command):
|
||||
var output = []
|
||||
OS.execute(command, [], true, output, true)
|
||||
# Remove trailing newline.
|
||||
return output[0].substr(0,len(output[0])-1)
|
||||
|
|
Loading…
Reference in a new issue