module ServicePrompter

Public Instance Methods

service_id(allow_none=false) click to toggle source
# File lib/pvdgm-svc-client/prompters/service_prompter.rb, line 3
def service_id(allow_none=false)
  return options[:service_id] if options[:service_id]
  return options[:service_id] = ENV['SERVICE_ID'] if ENV['SERVICE_ID']
  return options[:service_id] = prompt_for_service_id(allow_none)
end

Private Instance Methods

prompt_for_service_id(allow_none) click to toggle source
# File lib/pvdgm-svc-client/prompters/service_prompter.rb, line 11
def prompt_for_service_id(allow_none)
  result = get("services/services")

  (puts "No services have been defined. Cannot continue"; exit 1) if result.empty?

  # Build a menu of the services
  puts 
  return prompter.choose do | menu |
    menu.prompt = "Select the Service: "
    menu.choice("No Selection") { -1 } if allow_none
    result.each do | service |
      menu.choice(service['name']) { service['id'] }
    end
  end
end