From 73478b7e37f9d87fa33322483f4c83b6299887d4 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Sun, 11 Aug 2019 10:20:05 -0500 Subject: [PATCH] Added connect and disconnect stub commands, added autocomplete to help command. --- lib/ui/commands/connect_command.rb | 20 ++++++++++++++++++++ lib/ui/commands/disconnect_command.rb | 20 ++++++++++++++++++++ lib/ui/commands/help_command.rb | 12 ++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/ui/commands/connect_command.rb create mode 100644 lib/ui/commands/disconnect_command.rb diff --git a/lib/ui/commands/connect_command.rb b/lib/ui/commands/connect_command.rb new file mode 100644 index 0000000..e32139c --- /dev/null +++ b/lib/ui/commands/connect_command.rb @@ -0,0 +1,20 @@ +class IMICFPS + class Commands + class ConnectCommand < Command + def group + :global + end + + def command + :connect + end + + def handle(arguments, console) + end + + def usage + "Connect to a server.\n#{Style.highlight("connect")} #{Style.notice("[example.com:56789]")}" + end + end + end +end \ No newline at end of file diff --git a/lib/ui/commands/disconnect_command.rb b/lib/ui/commands/disconnect_command.rb new file mode 100644 index 0000000..31dcd49 --- /dev/null +++ b/lib/ui/commands/disconnect_command.rb @@ -0,0 +1,20 @@ +class IMICFPS + class Commands + class DisconnectCommand < Command + def group + :global + end + + def command + :disconnect + end + + def handle(arguments, console) + end + + def usage + "Disconnect from currently connected server, if any." + end + end + end +end \ No newline at end of file diff --git a/lib/ui/commands/help_command.rb b/lib/ui/commands/help_command.rb index 4b68c7e..7eaa7a4 100644 --- a/lib/ui/commands/help_command.rb +++ b/lib/ui/commands/help_command.rb @@ -13,6 +13,18 @@ class IMICFPS console.stdin(usage(arguments.first)) end + def autocomplete(console) + split = console.text_input.text.split(" ") + if !console.text_input.text.start_with?(" ") && split.size == 2 + list = console.abbrev_search(Commands::Command.list_commands.map { |cmd| cmd.command.to_s }, split.last) + if list.size == 1 + console.text_input.text = "#{split.first} #{list.first} " + elsif list.size > 1 + console.stdin(list.map { |cmd| Style.highlight(cmd) }.join(', ')) + end + end + end + def usage(command = nil) if command if cmd = Command.find(command)