Class: Engineyard::Local::Command::Help

Inherits:
Base show all
Defined in:
lib/engineyard-local/command/help.rb

Instance Attribute Summary

Attributes inherited from Base

#env, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from Vagrant::Command::Base

#cookbook_status, #initialize

Methods included from Helpers

#insert_linebreaks, #merge_run_options, #run

Constructor Details

This class inherits a constructor from Engineyard::Local::Command::Base

Instance Method Details

#exec(thor, *args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/engineyard-local/command/help.rb', line 6

def exec(thor, *args)
  list = Engineyard::Local::Command::Group.printable_tasks
  Thor::Util.thor_classes_in(thor.class).each do |klass|
    list += klass.printable_tasks(false)
  end

  truncate_output = true

  if !args.empty?
    list = list.select { |i| args.any? { |a| i.first =~ /^[\w\-]+\s+#{a}\b/ } }
    truncate_output = false
    list.sort!{ |a,b| a[0] <=> b[0] }.each do |h|
      thor.shell.say(h[0], nil, true)
      insert_linebreaks(h[1]).each do |line|
        thor.shell.say("#{' ' * 4}#{line}", nil, true)
      end
    end
  else
    list.sort!{ |a,b| a[0] <=> b[0] }

    thor.shell.say "Commands:"
    thor.shell.print_table(list, :indent => 2, :truncate => truncate_output)
    thor.shell.say
  end

end