Class: CBin::Config::Asker

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-tdf-bin/config/config_asker.rb

Instance Method Summary collapse

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_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_messageObject



52
53
54
# File 'lib/cocoapods-tdf-bin/config/config_asker.rb', line 52

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

#show_promptObject



7
8
9
# File 'lib/cocoapods-tdf-bin/config/config_asker.rb', line 7

def show_prompt
  print ' > '.green
end

#wellcome_messageObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cocoapods-tdf-bin/config/config_asker.rb', line 40

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