Sha256: 970a6edd1c5353acb9a39262dea1fa293bb212f77f664dcfab84294741a7fa24
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
Contents
require 'zendesk_apps_tools/common' module ZendeskAppsTools class Settings def get_settings_from(user_input, parameters) return {} if parameters.nil? parameters.inject({}) do |settings, param| if param[:default] input = user_input.get_value_from_stdin("Enter a value for parameter '#{param[:name]}' or press 'Return' to use the default value '#{param[:default]}':\n", :allow_empty => true) input = param[:default] if input.empty? elsif param[:required] input = user_input.get_value_from_stdin("Enter a value for required parameter '#{param[:name]}':\n") else input = user_input.get_value_from_stdin("Enter a value for optional parameter '#{param[:name]}' or press 'Return' to skip:\n", :allow_empty => true) end unless input.empty? input = (input =~ /^(true|t|yes|y|1)$/i) ? true : false if param[:type] == 'checkbox' settings[param[:name]] = input end settings end end end end
Version data entries
6 entries across 6 versions & 1 rubygems