lib/rudy/routines/handlers/rye.rb in rudy-0.9.8.008 vs lib/rudy/routines/handlers/rye.rb in rudy-0.9.8.009
- old
+ new
@@ -15,11 +15,12 @@
opts = {
:info => (@@global.verbose >= 2), # rudy -vv
:debug => false,
:user => current_machine_user,
:ostype => current_machine_os || :unix,
- :impltype => :linux
+ :impltype => :linux,
+ :info => STDOUT
}.merge opts
nickname = hostname
if hostname.kind_of? Rudy::Machine
hostname, nickname = hostname.dns_public, hostname.name
@@ -41,17 +42,20 @@
print_command user, nickname, cmd
end
end
if @@global.verbose > 0 && !@@global.quiet
+ box.stdout_hook do |content|
+ li content
+ end
# And this one gets called after each command method call.
box.post_command_hook do |ret|
print_response ret
end
end
- box.exception_hook(::Rye::CommandError, &rbox_exception_handler)
+ box.exception_hook(::Rye::Err, &rbox_exception_handler)
box.exception_hook(Exception, &rbox_exception_handler)
## It'd better for unknown commands to be handled elsewhere
## because it doesn't make sense to retry a method that doesn't exist
##box.exception_hook(Rye::CommandNotFound, &rbox_exception_handler)
@@ -119,22 +123,21 @@
end
def print_response(rap)
# Non zero exit codes raise exceptions so
# the erorrs have already been handled.
- return if rap.exit_code != 0
+ return if rap.exit_status != 0
if @@global.parallel
cmd, user = cmd.to_s, user.to_s
prompt = user == "root" ? "#" : "$"
li "%s@%s%s %s%s%s" % [rap.box.user, rap.box.nickname, prompt, rap.cmd.bright, $/, rap.stdout.inspect]
unless rap.stderr.empty?
le "#{rap.box.nickname}: " << rap.stderr.join("#{rap.box.nickname}: ")
end
else
- li ' ' << rap.stdout.join("#{$/} ") if !rap.stdout.empty?
- colour = rap.exit_code != 0 ? :red : :normal
+ colour = rap.exit_status != 0 ? :red : :normal
unless rap.stderr.empty?
le (" STDERR " << '-'*38).color(colour).bright
le " " << rap.stderr.join("#{$/} ").color(colour)
end
end
@@ -143,27 +146,26 @@
def rbox_exception_handler
Proc.new do |ex, cmd, user, host, nickname|
print_exception(user, host, cmd, nickname, ex)
unless @@global.parallel
- choice = Annoy.get_user_input('(S)kip (R)etry (F)orce (A)bort: ', nil, 3600) || ''
+ choice = Annoy.get_user_input('(S)kip (R)etry (I)nteractive (A)bort: ', nil, 3600) || ''
if choice.match(/\AS/i)
:skip
elsif choice.match(/\AR/i)
:retry # Tells Rye::Box#run_command to retry
- elsif choice.match(/\AF/i)
- @@global.force = true
- :retry
+ elsif choice.match(/\AI/i)
+ :interactive
else
exit 12
end
end
end
end
def print_exception(user, host, cmd, nickname, ex)
prefix = @@global.parallel ? "#{nickname}: #{cmd}: " : ""
- if ex.is_a?(::Rye::CommandError)
+ if ex.is_a?(::Rye::Err)
le prefix << ex.message.color(:red)
else
le prefix << "#{ex.class}: #{ex.message}".color(:red)
end
le ex.backtrace if Rudy.debug?