Sha256: 6a8bfe9eb1614602ea8d6a050d11a2dfec78e821134d9144b73e3eeb98465822

Contents?: true

Size: 978 Bytes

Versions: 8

Compression:

Stored size: 978 Bytes

Contents

require 'yaml'
require 'cocoapods-tj/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

      end

      def done_message

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cocoapods-tj-1.0.7 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.6 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.5 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.4 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.3 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.2 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.1 lib/cocoapods-tj/config/config_asker.rb
cocoapods-tj-1.0.0 lib/cocoapods-tj/config/config_asker.rb