Sha256: d2320e3d6dee42a17cb411a0ee0dd22a6e765ccc285ee152569eb44e1eeaea77
Contents?: true
Size: 827 Bytes
Versions: 30
Compression:
Stored size: 827 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] if input =~ options[:valid_regex] break else say(options[:error_msg], :red) end end input end def get_password_from_stdin(prompt) print "#{prompt} " password = STDIN.noecho(&:gets).chomp puts password end end end
Version data entries
30 entries across 30 versions & 2 rubygems