Class: Vbuilder::Generator::Application

Inherits:
Object
  • Object
show all
Extended by:
Shellwords
Defined in:
lib/vbuilder/generator/application.rb

Class Method Summary collapse

Class Method Details

.build_options(arguments) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/vbuilder/generator/application.rb', line 34

def build_options(arguments)
    env_opts_string = ENV['VBUILDER_OPTS'] || ""
    env_opts        = Vbuilder::Generator::Options.new(shellwords(env_opts_string))
    argument_opts   = Vbuilder::Generator::Options.new(arguments)

    env_opts.merge(argument_opts)
end

.run!(*arguments) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vbuilder/generator/application.rb', line 9

def run!(*arguments)
    options = build_options(arguments)

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

    if options[:show_version]
        $stderr.puts "Version: #{Vbuilder::Version.version}"
        return 1
    end

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

    begin
        generator = Vbuilder::Generator.new(options)
        generator.run
        return 0
    end
end