Class: EasyChangelog::TaskOptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_changelog/task_options_parser.rb

Class Method Summary collapse

Class Method Details

.parse(type, args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/easy_changelog/task_options_parser.rb', line 7

def self.parse(type, args)
  options = {}
  opts = OptionParser.new
  args = opts.order!(args) {}

  opts.banner = "Usage: rake changelog:#{type} [options]"

  opts.on('-u', '--user=ARG', 'Git Username') { |arg| options[:user] = arg }
  opts.on('-b', '--branch=ARG', 'Branch Name') { |arg| options[:branch_name] = arg }
  opts.on('-t', '--title=ARG', 'Changelog Title Entry') { |arg| options[:body] = arg }
  opts.on('-r', '--ref-id=ARG', 'Ref ID') { |arg| options[:ref_id] = arg }
  opts.on('-R', '--ref-type=ARG', 'Ref type (issues|pull|commit)') { |arg| options[:ref_type] = arg }
  opts.on('-c', '--card-id=ARG', 'Card ID') { |arg| options[:card_id] = arg }
  opts.on('-C', '--cards-url=ARG', 'Cards base URL') { |arg| options[:cards_url] = arg }

  opts.on('-h', '--help', 'Prints this helper') do
    puts opts
    exit
  end

  opts.parse!(args)

  options
end