Class: Commands::HelpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/helpcommand.rb

Instance Method Summary collapse

Constructor Details

#initialize(tracker) ⇒ HelpCommand

Returns a new instance of HelpCommand.



7
8
9
# File 'lib/commands/helpcommand.rb', line 7

def initialize(tracker)
  @tracker = tracker
end

Instance Method Details

#help(commandcontext) ⇒ Object



23
24
25
26
# File 'lib/commands/helpcommand.rb', line 23

def help(commandcontext)
  commandcontext.output 'Use pug help <command>'
  Meta::list_of_commands.each {|command| commandcontext.output command}
end

#run(commandcontext) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/commands/helpcommand.rb', line 11

def run(commandcontext)
  if commandcontext.number_of_arguments == 0
    help(commandcontext)
  else
    commandname = commandcontext.pop_argument!("")
    command = Meta::command_from_name(commandname, @tracker)
    if command != nil
      command.help(commandcontext)
    end
  end
end