Method: Linecook::Commands::Compile.parse

Defined in:
lib/linecook/commands/compile.rb

.parse(argv = ARGV) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/linecook/commands/compile.rb', line 26

def parse(argv=ARGV)
  super(argv) do |options|
    options.on('-I DIRECTORY', 'prepend to LOAD_PATH') do |path|
      $LOAD_PATH.unshift File.expand_path(path)
    end

    options.on('-r LIBRARY', 'require the library') do |path|
      require(path)
    end

    options.on('-G GEMNAME', 'add gem to cookbook path', :option_type => :list) do |name|
      specs = Gem.source_index.find_name(name)
      if specs.empty?
        raise CommandError, "could not find gem: #{name.inspect}"
      end
      (options[:cookbook_path] ||= []) << specs.first.full_gem_path
    end

    options.on('-g', '--gems', 'add latest cookbook gems') do |name|
      (options[:cookbook_path] ||= []).concat cookbook_gem_paths
    end

    options.on('-c', '--common', 'use common flags') do
      set_common_options(options)
    end

    if block_given?
      yield(options)
    end
  end
end