poll git commands from help page

This commit is contained in:
bleeptrack 2020-09-25 12:29:48 +02:00
parent ed56385d14
commit dafc5126f1

View file

@ -4,6 +4,7 @@ var thread
var history = [] var history = []
var history_position = 0 var history_position = 0
var git_commands = []
onready var input = $VBoxContainer/InputLine/Input onready var input = $VBoxContainer/InputLine/Input
onready var output = $VBoxContainer/TopHalf/Output onready var output = $VBoxContainer/TopHalf/Output
@ -31,6 +32,11 @@ func _ready():
push_error("Could not connect TextEditor's hide signal") push_error("Could not connect TextEditor's hide signal")
input.grab_focus() input.grab_focus()
var all_git_commands = repository.shell.run("git help -a | grep \"^ \\+[a-z-]\\+ \" -o | sed -e 's/^[ \t]*//'")
git_commands = Array(all_git_commands.split("\n"))
git_commands.pop_back()
print(git_commands)
func _input(event): func _input(event):
if history.size() > 0: if history.size() > 0:
if event.is_action_pressed("ui_up"): if event.is_action_pressed("ui_up"):
@ -114,11 +120,7 @@ func regenerate_completions_menu(new_text):
func generate_completions(command): func generate_completions(command):
if command.substr(0, 4) == "git ": if command.substr(0, 4) == "git ":
var rest = command.substr(4) var rest = command.substr(4)
var subcommands = [ var subcommands = git_commands
"commit",
"status",
"diff",
]
var results = [] var results = []
for sc in subcommands: for sc in subcommands: