class GitBumper::CLIParser
This is the parser for CLI
arguments.
Attributes
options[R]
Public Class Methods
new(argv)
click to toggle source
@param argv [Array<String>]
# File lib/git_bumper/cli_parser.rb, line 10 def initialize(argv) @argv = argv @parser = OptionParser.new @options = { klass: GitBumper::Tag, prefix: 'v', increment: :patch } end
Public Instance Methods
parse()
click to toggle source
# File lib/git_bumper/cli_parser.rb, line 18 def parse @parser.banner = 'Usage: git bump [options]' @parser .on('-b', '--build', 'Use build tags') do options[:klass] = GitBumper::BuildTag end .on('-p', '--prefix [PREFIX]', 'Set a prefix') do |prefix| options[:prefix] = prefix end .on('--major', 'Increments the major version') do options[:increment] = :major end .on('--minor', 'Increments the minor version') do options[:increment] = :minor end .on('-h', '--help', 'Prints this help') do puts @parser return false end @parser.parse!(@argv) end