Sha256: 2f71079c1829af202d01f17fe90c9c2d87b1e3be478fc08038cd0fe5a046e47a

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 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

1 entries across 1 versions & 1 rubygems

Version Path
phrase-0.4.15 lib/phrase/tool/options.rb