Sha256: cba3b81758718e0e98c9595b1b7fa12d8b872d9f294b18a5280e272c15c0ee7b
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
# -*- encoding : utf-8 -*- module Phrase::Tool::Commands class Base def initialize(options, args=[]) @options = options @args = args end def execute! raise "not implemented" end def require_auth_token! unless config.secret and config.secret.present? print_error "No auth token present. You need to initialize phrase first." exit_command end end def self.print_error(msg) $stderr.puts msg.red end def self.print_server_error(msg, location=nil) error_message = "#{msg}" error_message << " (#{location})" unless location.nil? print_error error_message end def self.print_message(msg) $stdout.puts msg end def self.exit_command(status = false) exit(status) end protected def get_option(name) options.get(name) end def api_client Phrase::Api::Client.new(config.secret) end def config @config ||= get_config end def get_config config = Phrase::Tool::Config.new config.load end def options @options end def print_error(msg) self.class.print_error(msg) end def print_server_error(message, location=nil) self.class.print_server_error(message, location) end def print_message(msg) self.class.print_message(msg) end def exit_command(status = false) self.class.exit_command(status) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phrase-0.4.15 | lib/phrase/tool/commands/base.rb |