class Wrake::Command::Options
Attributes
config_file[R]
env[R]
task_args[R]
task_name[R]
Public Class Methods
new(options = [])
click to toggle source
# File lib/wrake/command/options.rb, line 10 def initialize(options = []) @env = 'production' parse(options) end
Private Instance Methods
parse(options)
click to toggle source
# File lib/wrake/command/options.rb, line 16 def parse(options) @parser = OptionParser.new do |opts| opts.banner = "Usage: wrake task_name [params] [options]" parse_config_file(opts) parse_environment(opts) opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end @parser.parse!(options) parse_task_name(options) parse_task_args(options) rescue OptionParser::InvalidOption => e raise_error(e.message) end
parse_config_file(opts)
click to toggle source
# File lib/wrake/command/options.rb, line 47 def parse_config_file(opts) opts.on('-c', '--config-file CONFIG_FILE', "Set the config file to read from.") do |file| @config_file = file end end
parse_environment(opts)
click to toggle source
# File lib/wrake/command/options.rb, line 53 def parse_environment(opts) opts.on('-e', '--env ', "Set the environment. Defaults to 'production'") do |file| @env = file end end
parse_task_args(options)
click to toggle source
# File lib/wrake/command/options.rb, line 43 def parse_task_args(options) @task_args = options end
parse_task_name(options)
click to toggle source
# File lib/wrake/command/options.rb, line 39 def parse_task_name(options) @task_name = options.shift end
raise_error(message)
click to toggle source
# File lib/wrake/command/options.rb, line 35 def raise_error(message) raise Error, message + "\n\n#{@parser}" end