Class: Gumbo::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/gumbo/cli.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gumbo/cli.rb', line 12

def initialize(args)
  @options = {}

  OptionParser.new do |opts|
    opts.banner = "Usage: gumbo [options]"

    opts.on("-c", "--clean", "Delete the output directory before running") do |v|
      @options[:clean] = v
    end

    opts.on("-h", "--help", "Display this message") do |h|
      puts opts
      exit
    end

    opts.on("-s", "--source-dir [SOURCE_DIR]", "the source directory, defaults to '#{Gumbo::AssetBuilder::DEFAULT_SOURCE_DIR}'") do |v|
      @options[:source_dir] = v
    end

    opts.on("-o", "--output-dir [OUTPUT_DIR]", "the output directory, defaults to '#{Gumbo::AssetBuilder::DEFAULT_OUTPUT_DIR}'") do |v|
      @options[:output_dir] = v
    end

    opts.on("-p", "--packages-file [PACKAGES_FILE]", "the packages file, relative to the source directory, defaults to '#{Gumbo::AssetBuilder::DEFAULT_PACKAGES_FILE}'") do |v|
      @options[:packages_file] = v
    end

    opts.on("-m", "--manifest-file [MANIFEST_FILE]", "the manifest file, relative to the output directory, defaults to '#{Gumbo::AssetBuilder::DEFAULT_MANIFEST_FILE}'") do |v|
      @options[:manifest_file] = v
    end
  end.parse(args)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/gumbo/cli.rb', line 6

def options
  @options
end

Class Method Details

.run(args) ⇒ Object



8
9
10
# File 'lib/gumbo/cli.rb', line 8

def self.run(args)
  new(args).run
end

Instance Method Details

#runObject



45
46
47
# File 'lib/gumbo/cli.rb', line 45

def run
  Gumbo::AssetBuilder.build(@options)
end