Module: Mchat::Command::Help::InstanceMethods

Defined in:
lib/mchat/commands/help.rb

Instance Method Summary collapse

Instance Method Details

#help_command_run(subject = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mchat/commands/help.rb', line 33

def help_command_run(subject = nil)
  if !subject
    return help_help_doc
  end
  subject = subject && subject.strip
  catch :halt do
    CommandConditions.each do |command|
      help_condition = command[:help_condition]
      help_condition.each do |hc|
        if hc.match(subject)
          catch_subject =  $1 ? $1 : nil
          _dispatch(command[:help_doc], catch_subject)
          throw :halt
        end
      end
    end
  end
end

#help_help_docObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mchat/commands/help.rb', line 15

def help_help_doc
  cmd_list = ""
  CommandConditions.each do |c|
    cmd_list << "#{c[:description]}\n"
  end

  _puts %Q(
#{"Help: Index".style.bold}

Choose subject to help:

#{cmd_list}

e.g:
type `/h guide` you will find guide guide.
)
end