Module: Versionista

Defined in:
lib/versionista.rb

Defined Under Namespace

Classes: Manager

Constant Summary collapse

VERSION =
File.read(File.expand_path('../../VERSION', __FILE__))

Class Method Summary collapse

Class Method Details

.from_args(args) ⇒ Object



7
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
46
47
# File 'lib/versionista.rb', line 7

def self.from_args(args)
  options = {}

  optparse = OptionParser.new do |opts|
    opts.banner = <<-EOF
    Versionista! #{VERSION}


    Manage version files. To get started run

    $ versionista --init --version-file ./path/to/File
    EOF
      .gsub(/^\s*/,'')

    opts.on('-f', '--version-file FILE', 'Path to version file') do |file|
      options[:file] = File.expand_path(file)
    end

    opts.on('-b', '--bump WHICH', 'Bump: major/minor/patch') do |which|
      options[:which] = which
    end

    opts.on('-i', '--init', 'Initialize version file') do
      options[:init] = true
    end

    opts.on('-h', '--help', 'halp') do
      puts opts
      exit 0
    end
  end

  optparse.parse! args

  if options.empty?
    puts optparse
    exit 0
  end

  Manager.new(options[:init], options[:file], options[:which])
end