Sha256: 030fc1fadbfa010441fac1a97dda2cee02a595e9f197c6c279f2ebc33450cb2f
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
require 'commander/blank' require 'commander/command' module PolyglotIos module Command class Setup include Helper::Terminal include Helper::General def self.init(options = Commander::Command::Options.new) new(options).call end def initialize(options = Commander::Command::Options.new) @options = options end def call project_id = project_id_prompt language = language_prompt translations_path = translations_path_prompt sources_path = sources_path_prompt project = { id: project_id, path: translations_path, sourceFilesPath: sources_path } config = { language: language, projects: [project] } PolyglotIos::IO::Config.write(config) success end private # Project ID def project_id_prompt prompt.select('Choose a project: ', filtered_projects) end def projects prompt.say('Getting projects...') PolyglotIos::Resource::Project.token(token).depaginate.each_with_object({}) do |r, hash| hash[r.name] = r.id end end def filtered_projects projects.select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] }.sort_by { |p| p[0].downcase }.to_h end def option_query @option_query ||= @options.__hash__.fetch(:query, '') end # Language def language_prompt languages = {'Swift' => 'swift', 'Objective-C' => 'objc'} prompt.select('Choose a language: ', languages) end # Translations path def translations_path_prompt prompt.ask('Where would you like to store translation files (.strings)?', default: './Resources/Translations/') end # Sources path def sources_path_prompt prompt.ask('Where would you like to store source files?', default: './Common/Translations/') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ios_polyglot_cli-2.0.1 | lib/ios_polyglot_cli/commands/setup.rb |