Class: Tukune::OptionParser
- Inherits:
-
Object
- Object
- Tukune::OptionParser
- Defined in:
- lib/tukune/option_parser.rb
Instance Method Summary collapse
-
#initialize ⇒ OptionParser
constructor
A new instance of OptionParser.
- #options ⇒ Object
- #parse!(argv = @opt_parser.default_argv) ⇒ Object
Constructor Details
#initialize ⇒ OptionParser
Returns a new instance of OptionParser.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tukune/option_parser.rb', line 3 def initialize @opt_parser = ::OptionParser.new do |opt| opt. = 'Usage: tukune [OPTIONS]' opt.separator '' opt.separator 'Options' opt.on('-t', '--title TITLE', 'Pull request title') do |title| @title = title end opt.on('-b', '--body BODY', 'Pull request body') do |body| @body = body end opt.on('--target-path V,V...', Array) do |path| @target_paths = path end opt.on('-h', '--help', 'help') do puts @opt_parser end end end |
Instance Method Details
#options ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/tukune/option_parser.rb', line 31 def { title: @title, body: @body, target_paths: @target_paths || [] } end |
#parse!(argv = @opt_parser.default_argv) ⇒ Object
27 28 29 |
# File 'lib/tukune/option_parser.rb', line 27 def parse!(argv = @opt_parser.default_argv) @opt_parser.parse!(argv) end |