Class: Convertr::Runner::OptParser

Inherits:
Object
  • Object
show all
Defined in:
lib/convertr/runner.rb

Overview

{{{

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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

def self.parse(args)
  options = Convertr::Config.instance
  options.db_config_file = "~/.convertr/database.yml"
  options.settings_file = "~/.convertr/settings.yml"
  options.max_tasks = 0
  opts = OptionParser.new do |opts|
    opts.banner = "Usage: convertr [options]"
    opts.separator ""
    opts.separator "Specific options:"

    opts.on("-d", "--db_config_file [PATH_TO_DB_CONFIG]",
          "Specify path to database.yml file") do |dbc|
      options.db_config_file = dbc
    end

    opts.on("-c", "--settings_file [PATH_TO_CONFIG]",
          "Specify path to settings.yml file") do |c|
      options.settings_file = c
    end

    opts.on("-m", "--max_tasks N", Integer,
          "Specify the maximum tasks to complete") do |m|
      options.max_tasks = m
          end
  end
  opts.parse!(args)
  options
end