Sha256: cb78bf45b60486a85107f668e89251937373eb7ca3d12241ddcddafba9cdfa85
Contents?: true
Size: 977 Bytes
Versions: 4
Compression:
Stored size: 977 Bytes
Contents
require "git_commands/colorize" module GitCommands using Colorize module Prompt VALID_ANSWERS = %w[Y y N n] class AbortError < StandardError; end def out @out ||= STDOUT end def warning(message, char = "*") spacer = (char * (message.size + 4)).grey out.puts "\n", spacer, "#{char} #{message.to_s.yellow} #{char}", spacer, "\n" end def error(message, error = StandardError) out.puts message.to_s.red yield if block_given? fail error, message end def success(message) out.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) out.print message.cyan input end def input STDIN.gets.chomp end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
git_commands-3.0.4 | lib/git_commands/prompt.rb |
git_commands-3.0.3 | lib/git_commands/prompt.rb |
git_commands-3.0.2 | lib/git_commands/prompt.rb |
git_commands-3.0.1 | lib/git_commands/prompt.rb |