Class: ReleaseManager::ReleaseModCli

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

Class Method Summary collapse

Class Method Details

.runObject



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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/release_manager/cli/release_mod_cli.rb', line 21

def self.run
  options = {}
  OptionParser.new do |opts|
    opts.program_name = 'release-mod'
    opts.version = ReleaseManager::VERSION
    opts.on_head(<<-EOF

Summary: Bumps the module version to the next revision and
     updates the changelog.md file with the new
     version by reading the metadata.json file. This should
     be run inside a module directory.

    EOF
    )
    opts.on("-d", "--dry-run", "Do a dry run, without making changes") do |c|
      options[:dry_run] = c
    end
    opts.on('-a', '--auto', 'Run this script without interaction') do |c|
      options[:auto] = c 
    end
    opts.on('-l', '--level [LEVEL]', 'Semantic versioning level to bump (major,minor,patch), defaults to patch') do |c|
      options[:level] = c 
    end
    opts.on('-m', '--module-path [MODULEPATH]', "The path to the module, defaults to #{Dir.getwd}") do |c|
      options[:path] = c
    end
    opts.on('-b', '--no-bump', "Do not bump the version in metadata.json") do |c|
      options[:bump] = c
    end
    opts.on('-r', '--repo [REPO]', "The repo to use, defaults to repo found in the metadata source") do |c|
      options[:repo] = c
    end
    opts.on('--verbose', "Extra logging") do |c|
      options[:verbose] = c
    end
    opts.on('-r', '--remote-release', "Perform a remote release (For CI systems)") do |c|
      options[:remote] = true
    end
  end.parse!

  # default to patch
  options[:level] ||= 'patch'

  # validate -l, --level input
  unless %w(major minor patch).include?(options[:level])
    puts "expected major minor or patch for parameter -l,  --level. You supplied #{options[:level]}.".fatal
    exit 1
  end
  r = options[:remote] ?
      RemoteRelease.new(options[:path], options) : Release.new(options[:path], options)
  r.run
end