Class: YMDP::Compiler::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/ymdp/compiler/options.rb

Overview

Command-line options processor for Compiler module.

Class Method Summary collapse

Class Method Details

.parseObject

Parse command line options into an options hash.



8
9
10
11
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
44
45
# File 'lib/ymdp/compiler/options.rb', line 8

def self.parse
  options = {
    :commit => false,
    :branch => "master",
    :base_path => BASE_PATH,
    :servers => SERVERS
  }
  OptionParser.new do |opts|
    options[:commit] = false
    options[:verbose] = CONFIG.verbose?
    opts.banner = "Usage: build.rb [options]"

    opts.on("-d", "--domain [domain]", "Force Domain") do |v|
      options[:domain] = v
    end
    opts.on("-b", "--branch [branch]", "Current Branch") do |v|
      options[:branch] = v
    end
    opts.on("-m", "--message [message]", "Commit Message") do |v|
      options[:commit] = true
      options[:message] = v
    end
    opts.on("-n", "--no-commit", "Don't Commit") do |v|
      options[:commit] = false
    end
    opts.on("-v", "--verbose", "Verbose (show all file writes)") do |v|
      options[:verbose] = true
    end
    opts.on("-r", "--rake [task]", "Execute Rake task") do |v|
      options[:rake] = v
    end
    opts.on("-c", "--compress", "Compress JavaScript and CSS") do |v|
      options[:compress] = v
    end
  end.parse!
    
  options
end