From 374db542f3b078c22cae67dfd411e9aea2828a4b Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Mon, 28 Sep 2020 17:39:16 +0200 Subject: [PATCH] Adding command description to completions --- terminal.gd | 12 ++++++++++++ terminal.tscn | 1 + 2 files changed, 13 insertions(+) diff --git a/terminal.gd b/terminal.gd index 6462bc1..5376027 100644 --- a/terminal.gd +++ b/terminal.gd @@ -4,6 +4,7 @@ var thread var history_position = 0 var git_commands = [] +var git_commands_help = [] onready var input = $VBoxContainer/InputLine/Input onready var output = $VBoxContainer/TopHalf/Output @@ -37,6 +38,12 @@ func _ready(): git_commands[i] = git_commands[i].strip_edges(true, true) git_commands.pop_back() + var all_git_commands_help = repository.shell.run("git help -a | grep \" [A-Z].\\+$\" -o") + git_commands_help = Array(all_git_commands_help.split("\n")) + for i in range(git_commands_help.size()): + git_commands_help[i] = git_commands_help[i].strip_edges(true, true) + git_commands_help.pop_back() + completions.hide() history_position = game.state["history"].size() @@ -127,6 +134,11 @@ func regenerate_completions_menu(new_text): for c in filtered_comp: var child = completions.create_item() child.set_text(0, c) + if c.split(" ").size() >= 2: + var subcommand = c.split(" ")[1] + var idx = git_commands.find(subcommand) + if idx >= 0: + child.set_text(1, git_commands_help[idx]) func relevant_subcommands(): var result = {} diff --git a/terminal.tscn b/terminal.tscn index 28ec6dc..8b3db1b 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -55,6 +55,7 @@ anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 margin_top = -223.0 +columns = 2 hide_root = true __meta__ = { "_edit_use_anchors_": false