Sha256: 13e0ad6ca47664074f033de68757806d6561db27c08973ddad8071ef497506db
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
require 'faraday' module ZendeskAppsTools module Common def api_request(url, request = Faraday.new) request.get(url) end def say_error_and_exit(msg) say msg, :red exit 1 end def get_value_from_stdin(prompt, opts = {}) options = { valid_regex: opts[:allow_empty] ? /^.*$/ : /\S+/, error_msg: 'Invalid, try again:', allow_empty: false }.merge(opts) while input = ask(prompt) return "" if input.empty? && options[:allow_empty] unless input =~ options[:valid_regex] say(options[:error_msg], :red) else break end end return input end def get_password_from_stdin(prompt, opts = {}) print "#{prompt} " password = STDIN.noecho(&:gets).chomp puts password end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zendesk_apps_tools-1.21.1 | lib/zendesk_apps_tools/common.rb |