Module: Parser

Defined in:
lib/tasks/helpers/parser.rb

Overview

Usage of names arguments in Rake as shown here: www.mikeball.us/blog/rake-option-parser/

Instance Method Summary collapse

Instance Method Details

#parse_options(command) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tasks/helpers/parser.rb', line 5

def parse_options(command)
  options = {}
  option_parser = OptionParser.new
  option_parser.banner = "Usage: rake #{command} [options]"

  case command
  when "mariadb_temporal_tables:gen_migration_application"
    setup_parser_for_gen_migration_application(option_parser, options)
  when "mariadb_temporal_tables:gen_migration_system"
    setup_parser_for_gen_migration_system(option_parser, options)
  else
    raise "Unable to parse options for unknown command: #{command}"
  end

  args = option_parser.order!(ARGV) {}
  option_parser.parse!(args)
  options
end