Class: Propel::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/propel/option_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse!(args = [ ]) ⇒ Object



6
7
8
# File 'lib/propel/option_parser.rb', line 6

def self.parse!(args = [ ])
  new.parse!(args)
end

Instance Method Details

#parse!(args) ⇒ Object



10
11
12
13
14
# File 'lib/propel/option_parser.rb', line 10

def parse!(args)
  options = {}
  parser(options).parse!(args)
  options
end

#parser(options) ⇒ Object



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
# File 'lib/propel/option_parser.rb', line 16

def parser(options)
  ::OptionParser.new do |parser|
    parser.banner = "Usage: propel [options]\n\n"

    parser.on('-c', '--[no-]color', '--[no-]colour', 'Toggle colored output. Color is off by default.') do |o|
      options[:color] = o
    end

    parser.on('-f', '--fix-ci', 'When CI is broken use --fix-ci to fix the build.') do |o|
      options[:fix_ci] = o
    end

    parser.on('-r', '--[no-]rebase', 'Use --no-rebase when you don\'t want to rebase.  Rebase is used by default.') do |o|
      options[:rebase] = o
    end

    parser.on('-s', '--status-url STATUS_URL', 'Location of build status feed.') do |build_status_url|
      options[:status_url] = build_status_url
    end

    parser.on('-v', '--[no-]verbose', 'Turn on verbose output from git.') do |o|
      options[:verbose] = o
    end

    parser.on('-w', '--[no-]wait', 'Waits for fixes to remote build.') do |o|
      options[:wait] = o
    end
  end
end