Class: Tukune::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/tukune/option_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeOptionParser

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.banner = '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

#optionsObject



31
32
33
34
35
36
37
# File 'lib/tukune/option_parser.rb', line 31

def options
  {
    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