Sha256: 12f1e10f3e8a40f33459829e4bcb10948a43ebfb16f6a7cbf3e5aa128e79ce99

Contents?: true

Size: 675 Bytes

Versions: 6

Compression:

Stored size: 675 Bytes

Contents

# -*- encoding : utf-8 -*-

require File.expand_path('../options_factory', __FILE__)

class Phrase::Tool::Options
  def initialize(args, command="")
    @command = command
    @data = Phrase::Tool::Commands.possible_commands_with_options
    options.parse!(args)
  end
  
  def get(name)
    return @data.fetch(command_name).fetch(name.to_sym)
  rescue => e
    $stderr.puts "Invalid or missing option \"#{name}\" for command \"#{command_name}\""
  end
  
private
  def options
    OptionsFactory.options_for(command_name, @data)
  end
  
  def command_name
    @command_name ||= (@command.present? and @data.has_key?(@command.to_sym)) ? @command.to_sym : :default
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
phrase-0.4.14 lib/phrase/tool/options.rb
phrase-0.4.13 lib/phrase/tool/options.rb
phrase-0.4.12 lib/phrase/tool/options.rb
phrase-0.4.11 lib/phrase/tool/options.rb
phrase-0.4.10 lib/phrase/tool/options.rb
phrase-0.4.9 lib/phrase/tool/options.rb