Class: BumperPusher::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/bumper_pusher/parser.rb

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



6
7
# File 'lib/bumper_pusher/parser.rb', line 6

def initialize
end

Instance Method Details

#parse_optionsObject



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
46
47
48
49
# File 'lib/bumper_pusher/parser.rb', line 9

def parse_options
  options = { dry_run: false, bump_number: :patch, changelog: false, bump: true, commit: true, build: true, push: true, install: true }

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

    opts.on("-d", "--dry-run", "Dry run") do |v|
      options[:dry_run] = v
    end
    opts.on("-r", "--release", "Bump release version") do |_v|
      options[:bump_number] = :major
    end
    opts.on("-m", "--minor", "Bump minor version") do |_v|
      options[:bump_number] = :minor
    end
    opts.on("-p", "--patch", "Bump patch version") do |_v|
      options[:bump_number] = :patch
    end
    opts.on("-r", "--revert", "Revert last bump") do |v|
      options[:revert] = v
    end
    opts.on("-i", "--[no-]install", "Install this gem after push it. Default is true.") do |v|
      options[:install] = v
    end
    opts.on("-b", "--beta", "Build beta gem without commit and push") do |v|
      options[:beta] = v
      options[:bump] = v
      options[:build] = v
      options[:commit] = !v
      options[:push] = !v
    end
    opts.on("-v", "--version", "Print version number") do |_v|
      puts "Version: #{BumperPusher::VERSION}"
      exit
    end
    opts.on("-g", "--gen-changelog", "Auto generation of changelog and pushing it origin. Default is false") do |v|
      options[:changelog] = v
    end        
  end.parse!
  options
end