Class: Moonwalkair::Generator::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/moonwalkair/generator/application.rb

Class Method Summary collapse

Class Method Details

.run!(*arguments) ⇒ Object



5
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/moonwalkair/generator/application.rb', line 5

def run!(*arguments)
  options = Moonwalkair::Generator::Options.new(arguments)

  if options[:invalid_argument]
    $stderr.puts options[:invalid_argument]
    options[:show_help] = true
  end

  if options[:show_help]
    $stderr.puts options.opts
    return 1
  end

  if options[:project_name].nil? || options[:project_name].squeeze.strip == ""
    $stderr.puts options.opts
    return 1
  end

  begin
    generator = Moonwalkair::Generator.new(options)
    generator.run
    return 0
  rescue Moonwalkair::FileAlreadyExist
    $stderr.puts "The directory #{options[:project_name]} already exists. Maybe move it out of the way before continuing?"
    return 1
  end
end