Sha256: 76514b38c6f460ba687c972d6cd4b443b4f2f5c64e963a135216506470acf5ac

Contents?: true

Size: 1.38 KB

Versions: 32

Compression:

Stored size: 1.38 KB

Contents

require 'yaml'
require 'cocoapods-tdf-bin/config/config'

module CBin
  class Config
    class Asker
      def show_prompt
        print ' > '.green
      end

      def ask_with_answer(question, pre_answer, selection)
        print "\n#{question}\n"

        print_selection_info = lambda {
          print "可选值:[ #{selection.join(' / ')} ]\n" if selection
        }
        print_selection_info.call
        print "旧值:#{pre_answer}\n" unless pre_answer.nil?

        answer = ''
        loop do
          show_prompt
          answer = STDIN.gets.chomp.strip

          if answer == '' && !pre_answer.nil?
            answer = pre_answer
            print answer.yellow
            print "\n"
          end

          next if answer.empty?
          break if !selection || selection.include?(answer)

          print_selection_info.call
        end

        answer
      end

      def wellcome_message
        print <<~EOF

          开始设置二进制化初始信息.
          所有的信息都会保存在 #{CBin.config.config_file} 文件中.
          %w[bin_dev.yml bin_debug_iphoneos.yml bin_release_iphoneos.yml] 
          你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:

          #{CBin.config.default_config.to_yaml}
        EOF
      end

      def done_message
        print "\n设置完成.\n".green
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cocoapods-tdf-bin-0.0.43 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.42 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.41 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.40 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.39 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.37 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.36 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.35 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.34 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.33 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.32 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.31 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.30 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.29 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.28 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.26 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.25 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.24 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.23 lib/cocoapods-tdf-bin/config/config_asker.rb
cocoapods-tdf-bin-0.0.22 lib/cocoapods-tdf-bin/config/config_asker.rb