Sha256: 7bb5125128601f8e46fd91b4486c97df765ee1fa3ef3d413cb62931b3b59866f
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# -*- encoding : utf-8 -*- class Phrase::Tool::Commands::Init < Phrase::Tool::Commands::Base def initialize(options, args) super(options, args) end def execute! secret = options.get(:secret) if secret.present? config.secret = secret print_message "Wrote secret to config file .phrase" default_locale_name = options.get(:default_locale) create_locale(default_locale_name) make_locale_default(default_locale_name) else print_auth_token_error exit_command end end private def create_locale(name) begin api_client.create_locale(name) print_message "Created locale \"#{name}\"".green rescue Exception => e print_message "Notice: Locale \"#{name}\" could not be created (maybe it already exists)".light_red end end def make_locale_default(name) begin api_client.make_locale_default(name) print_message "Locale \"#{name}\" is now the default locale".green rescue Exception => e print_message "Notice: Locale \"#{name}\" could not be made the default locale".light_red print_server_error(e.message) end end def print_auth_token_error print_error "No auth token was given" print_error "Please provide the --secret=YOUR_SECRET parameter." end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
phrase-0.3.1 | lib/phrase/tool/commands/init.rb |
phrase-0.3.0 | lib/phrase/tool/commands/init.rb |