Class: GitBumper::CLIParser
- Inherits:
-
Object
- Object
- GitBumper::CLIParser
- Defined in:
- lib/git_bumper/cli_parser.rb
Overview
This is the parser for CLI arguments.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLIParser
constructor
A new instance of CLIParser.
- #parse ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLIParser
Returns a new instance of CLIParser.
10 11 12 13 14 15 16 |
# File 'lib/git_bumper/cli_parser.rb', line 10 def initialize(argv) @argv = argv @parser = OptionParser.new = { klass: GitBumper::Tag, prefix: 'v', increment: :patch } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/git_bumper/cli_parser.rb', line 7 def end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git_bumper/cli_parser.rb', line 18 def parse @parser. = 'Usage: git bump [options]' @parser .on('-b', '--build', 'Use build tags') do [:klass] = GitBumper::BuildTag end .on('-p', '--prefix [PREFIX]', 'Set a prefix') do |prefix| [:prefix] = prefix end .on('--major', 'Increments the major version') do [:increment] = :major end .on('--minor', 'Increments the minor version') do [:increment] = :minor end .on('-h', '--help', 'Prints this help') do puts @parser return false end @parser.parse!(@argv) end |