Class: CyberarmEngine::Console::HelpCommand
  
  
  
  
  
    - Inherits:
- 
      Command
      
        
          - Object
- Command
- CyberarmEngine::Console::HelpCommand
 show all
    - Defined in:
- lib/cyberarm_engine/console/commands/help_command.rb
 
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Command
  find, #get, #handle_subcommand, inherited, #initialize, list_commands, #set, #setup, setup, #subcommand, use
  
    Instance Method Details
    
      
  
  
    #autocomplete(console)  ⇒ Object 
  
  
  
  
    | 
18
19
20
21
22
23
24
25
26
27
28 | # File 'lib/cyberarm_engine/console/commands/help_command.rb', line 18
def autocomplete(console)
  split = console.text_input.text.split(" ")
  if !console.text_input.text.start_with?(" ") && split.size == 2
    list = console.abbrev_search(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 | 
 
    
      
  
  
    #command  ⇒ Object 
  
  
  
  
    | 
10
11
12 | # File 'lib/cyberarm_engine/console/commands/help_command.rb', line 10
def command
  :help
end | 
 
    
      
  
  
    #group  ⇒ Object 
  
  
  
  
    | 
6
7
8 | # File 'lib/cyberarm_engine/console/commands/help_command.rb', line 6
def group
  :global
end | 
 
    
      
  
  
    #handle(arguments, console)  ⇒ Object 
  
  
  
  
    | 
14
15
16 | # File 'lib/cyberarm_engine/console/commands/help_command.rb', line 14
def handle(arguments, console)
  console.stdin(usage(arguments.first))
end | 
 
    
      
  
  
    #usage(command = nil)  ⇒ Object 
  
  
  
  
    | 
30
31
32
33
34
35
36
37
38
39
40 | # File 'lib/cyberarm_engine/console/commands/help_command.rb', line 30
def usage(command = nil)
  if command
    if cmd = Command.find(command)
      cmd.usage
    else
      "#{Style.error(command)} is not a command"
    end
  else
    "Available commands:\n#{Command.list_commands.map { |cmd| Style.highlight(cmd.command).to_s }.join(', ')}"
  end
end |