Class: CBin::Config_Hot_Key::Asker
- Inherits:
-
Object
- Object
- CBin::Config_Hot_Key::Asker
- Defined in:
- lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb
Instance Method Summary collapse
- #ask_with_answer(question, pre_answer, selection) ⇒ Object
- #done_message ⇒ Object
- #show_prompt ⇒ Object
- #wellcome_message ⇒ Object
Instance Method Details
#ask_with_answer(question, pre_answer, selection) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb', line 11 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 |
#done_message ⇒ Object
52 53 54 |
# File 'lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb', line 52 def print "\n设置完成.\n".green end |
#show_prompt ⇒ Object
7 8 9 |
# File 'lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb', line 7 def show_prompt print ' > '.green end |
#wellcome_message ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb', line 40 def print "\n \u5F00\u59CB\u8BBE\u7F6E\u5FEB\u6377\u952E pod bin imy.\n \u6240\u6709\u7684\u4FE1\u606F\u90FD\u4F1A\u4FDD\u5B58\u5728 \#{CBin.config_hot_key.config_file} \u6587\u4EF6\u4E2D.\n %w[hot_key.yaml] \n \u4F60\u53EF\u4EE5\u5728\u5BF9\u5E94\u76EE\u5F55\u4E0B\u624B\u52A8\u6DFB\u52A0\u7F16\u8F91\u8BE5\u6587\u4EF6. \u6587\u4EF6\u5305\u542B\u7684\u914D\u7F6E\u4FE1\u606F\u6837\u5F0F\u5982\u4E0B\uFF1A\n\n \#{CBin.config_hot_key.default_config.to_yaml}\n EOF\nend\n" |