class Object

Public Instance Methods

ask(statement, *args) click to toggle source
# File lib/pullrequest/thor.rb, line 6
def ask(statement, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  color = args.first    
  statement << " [#{options[:required] ? 'required' : 'optional'}]\n>"
  begin
    response = ask_original(statement, color, options)
    if options[:required] && response == ''
      raise Thor::RequiredArgumentMissingError
    end
    response
  rescue Interrupt
    exit_gracefully
  rescue Thor::RequiredArgumentMissingError
    say "Error: required", :red
    retry
  end
end
Also aliased as: ask_original
ask_bool(y_or_n, statement, color) click to toggle source
# File lib/pullrequest/thor.rb, line 38
def ask_bool(y_or_n, statement, color)
  ask_original(statement, color, add_to_history: false, limited_to: %w[yes no y n])[0] == y_or_n
end
ask_original(statement, *args)
Alias for: ask
exit_gracefully() click to toggle source
# File lib/pullrequest/thor.rb, line 42
def exit_gracefully
  say "[cancelled]", :red
  exit 0
end
no?(statement, color = nil) click to toggle source
# File lib/pullrequest/thor.rb, line 24
def no?(statement, color = nil)
  ask_bool('n', statement, color)
rescue Interrupt
  exit_gracefully
end
yes?(statement, color = nil) click to toggle source
# File lib/pullrequest/thor.rb, line 30
def yes?(statement, color = nil)
  ask_bool('y', statement, color)
rescue Interrupt
  exit_gracefully
end