Sha256: 162ab93562840eb35c9160d0b50f5ff00996a6754f1d28cde781261f6d074517

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

require 'commander/blank'
require 'commander/command'

module PolyglotIos
  module Command
    class Setup < Projects
      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
      
      # 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

7 entries across 7 versions & 1 rubygems

Version Path
ios_polyglot_cli-2.4.0 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.3.0 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.2.2 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.2.1 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.2.0 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.1.1 lib/ios_polyglot_cli/commands/setup.rb
ios_polyglot_cli-2.1.0 lib/ios_polyglot_cli/commands/setup.rb