Sha256: 2540bc52c9786f3192e87c73596021d9986364125be60a3466c8ca7aa7c08de5
Contents?: true
Size: 901 Bytes
Versions: 1
Compression:
Stored size: 901 Bytes
Contents
require 'git_commands/colorize' module GitCommands module Prompt VALID_ANSWERS = %w[Y y N n] class AbortError < StandardError; end def warning(message, char = '*') spacer = (char * (message.size + 4)).grey puts "\n", spacer, "#{char} #{message.to_s.yellow} #{char}", spacer, "\n" end def error(message, error = StandardError) puts message.to_s.red yield if block_given? fail error, message end def success(message) puts message.to_s.green end def confirm(message) res = begin ask "#{message} (Y/N)?" end until VALID_ANSWERS.include?(res) case res when /y/i yield else error('Aborted operation!', AbortError) end end private def ask(message) print message.cyan input end def input STDIN.gets.chomp end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_commands-2.1.0 | lib/git_commands/prompt.rb |