Sha256: dab6fd69d18d79223fa0ea3e2872b6b3ccb13870d9f73eb4e6e3437ed68afa62

Contents?: true

Size: 1.36 KB

Versions: 18

Compression:

Stored size: 1.36 KB

Contents

require 'yaml'
require 'cocoapods-fy-bin/config/config_hot_key'

module CBin
  class Config_Hot_Key
    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

          开始设置快捷键 pod bin imy.
          所有的信息都会保存在 #{CBin.config_hot_key.config_file} 文件中.
          %w[hot_key.yaml] 
          你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:

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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cocoapods-fy-bin-0.1.8 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.7 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.6 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.5 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.4 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.3 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.2 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.1 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.1.0 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.9 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.8 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.7 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.6 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.5 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.4 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.3 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.2 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
cocoapods-fy-bin-0.0.1 lib/cocoapods-fy-bin/config/config_hot_key_asker.rb