Sha256: 76b60c468023ff0a1413beea9e3142d1c87ba389b392341bd2bd96b57fa74fed

Contents?: true

Size: 797 Bytes

Versions: 18

Compression:

Stored size: 797 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 => _
    $stderr.puts "Invalid or missing option \"#{name}\" for command \"#{command_name}\""
  end

  def set?(name)
    return @data.fetch(command_name)[name.to_sym]
  rescue => _
    $stderr.puts "Invalid 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

18 entries across 18 versions & 1 rubygems

Version Path
phrase-0.4.33 lib/phrase/tool/options.rb
phrase-0.4.32 lib/phrase/tool/options.rb
phrase-0.4.31 lib/phrase/tool/options.rb
phrase-0.4.30 lib/phrase/tool/options.rb
phrase-0.4.29 lib/phrase/tool/options.rb
phrase-0.4.28 lib/phrase/tool/options.rb
phrase-0.4.27 lib/phrase/tool/options.rb
phrase-0.4.26 lib/phrase/tool/options.rb
phrase-0.4.25 lib/phrase/tool/options.rb
phrase-0.4.24 lib/phrase/tool/options.rb
phrase-0.4.23 lib/phrase/tool/options.rb
phrase-0.4.22 lib/phrase/tool/options.rb
phrase-0.4.21 lib/phrase/tool/options.rb
phrase-0.4.20 lib/phrase/tool/options.rb
phrase-0.4.19 lib/phrase/tool/options.rb
phrase-0.4.18 lib/phrase/tool/options.rb
phrase-0.4.17 lib/phrase/tool/options.rb
phrase-0.4.16 lib/phrase/tool/options.rb