mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Added connect and disconnect stub commands, added autocomplete to help command.
This commit is contained in:
20
lib/ui/commands/connect_command.rb
Normal file
20
lib/ui/commands/connect_command.rb
Normal file
@@ -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
|
||||
20
lib/ui/commands/disconnect_command.rb
Normal file
20
lib/ui/commands/disconnect_command.rb
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user