Class: Papago::Actions::Switch
- Inherits:
-
Object
- Object
- Papago::Actions::Switch
- Defined in:
- lib/papago/actions/switch.rb
Constant Summary collapse
- CHOICES =
%w{baidu openai qcloud youdao}
Class Method Summary collapse
Class Method Details
.process(config:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/papago/actions/switch.rb', line 6 def self.process(config:) prompt = TTY::Prompt.new choice = prompt.select('Choose a service?', CHOICES) config.set('translator.service_name', value: choice) config.write(force: true) if choice == 'openai' and (config.fetch('openai.endpoint').nil? or prompt.yes?('Update endpoint?')) if endpoint = prompt.ask('OpenAI endpoint:') config.set('openai.endpoint', value: endpoint) config.write(force: true) end end end |