Class: Harbor::Generator::HelpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor/generator/help.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HelpCommand

Returns a new instance of HelpCommand.



7
8
9
# File 'lib/harbor/generator/help.rb', line 7

def initialize(options)
  @command = options.first
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/harbor/generator/help.rb', line 11

def run
  if @command
    generator = Harbor::Generator.generators["harbor:#{@command}"]

    if !generator
      puts "Command '#{@command}' does not exist."
    else
      if generator.help.empty?
        puts "No help available for '#{@command}'."
      else
        puts generator.help
      end
    end

    exit(1)
  else
    puts Harbor::Generator.usage('harbor')
    exit(1)
  end
end