added basic help command
This commit is contained in:
@@ -13,7 +13,7 @@ var fileSystem: Dictionary = {
|
|||||||
"special": {
|
"special": {
|
||||||
"notes.txt": "test",
|
"notes.txt": "test",
|
||||||
"secrets": {
|
"secrets": {
|
||||||
"password.txt": 123
|
"password.txt": "123"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -26,6 +26,7 @@ func _ready() -> void:
|
|||||||
terminalLine.text = "user@work "+ directory + " "
|
terminalLine.text = "user@work "+ directory + " "
|
||||||
UpdateCaretPos()
|
UpdateCaretPos()
|
||||||
blink_timer.start()
|
blink_timer.start()
|
||||||
|
Help()
|
||||||
|
|
||||||
# --- Caret Blinking Logic ---
|
# --- Caret Blinking Logic ---
|
||||||
func _on_caret_timer_timeout() -> void:
|
func _on_caret_timer_timeout() -> void:
|
||||||
@@ -94,6 +95,10 @@ func EnterCommand() -> void:
|
|||||||
for child in historyContainer.get_children():
|
for child in historyContainer.get_children():
|
||||||
if child != terminalLine:
|
if child != terminalLine:
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
|
"help":
|
||||||
|
|
||||||
|
Help()
|
||||||
|
|
||||||
"":
|
"":
|
||||||
pass
|
pass
|
||||||
_:
|
_:
|
||||||
@@ -181,7 +186,24 @@ func RetrieveData(inputPath: String):
|
|||||||
CreateHistoryEntry(str(content))
|
CreateHistoryEntry(str(content))
|
||||||
else:
|
else:
|
||||||
CreateHistoryEntry("cat: " + targetFileName + ": No such file or directory")
|
CreateHistoryEntry("cat: " + targetFileName + ": No such file or directory")
|
||||||
|
|
||||||
|
func Help(commandName: String = "default"):
|
||||||
|
for child in historyContainer.get_children():
|
||||||
|
if child != terminalLine:
|
||||||
|
child.queue_free()
|
||||||
|
match commandName:
|
||||||
|
"default": CreateHistoryEntry("--- AVAILABLE COMMANDS ---
|
||||||
|
ls (or list) [folder] : List all files and directories/folders
|
||||||
|
cd [folder] : Change directory (use '..' to go up a directory/folder)
|
||||||
|
cat (or view) [file] : Read the contents of a file
|
||||||
|
clear (or cls) : Clear the terminal screen
|
||||||
|
help : Show this menu
|
||||||
|
-------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func UpdateCaretPos():
|
func UpdateCaretPos():
|
||||||
var last_char_index = terminalLine.text.length() - 1
|
var last_char_index = terminalLine.text.length() - 1
|
||||||
var char_rect = terminalLine.get_character_bounds(max(0, last_char_index))
|
var char_rect = terminalLine.get_character_bounds(max(0, last_char_index))
|
||||||
|
|||||||
Reference in New Issue
Block a user