On Wed, 1 Nov 2006 10:50:12 -0700
Jamis Buck <[EMAIL PROTECTED]> wrote:

> I've considered this, but I don't want this behavior in general. For
> instance, consider the long-running process that emits some progress
> indicator character, like a '.', each time some increment of the
> operation finishes. A newline may not be emitted for many minutes,
> but you'd like to see some progress being made.

Good point. That's the sort of use case I was thinking of but could not
articulate.

> For an action that you know will not behave like that, though, it
> might be a nice option to specify that you want line buffering.
> Perhaps as an option to run:
> 
>    run "some command", :buffer => true do |ch, stream, out|
>      ...
>    end

I like that. But instead of :buffer, perhaps :per_line_output. Or
something like that.

I've attached a patch--but haven't actually tried it yet. Later today
I'll likely be using capistrano to deploy some stuff and will try it out
then.

- Stephen



--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---
Index: lib/capistrano/actor.rb
===================================================================
--- lib/capistrano/actor.rb     (revision 5385)
+++ lib/capistrano/actor.rb     (working copy)
@@ -42,6 +42,15 @@
       ch[:actor].logger.send(level, out, "#{stream} :: #{ch[:host]}")
     end
 
+    self.per_line_output_proc = Proc.new do |ch, stream, out|
+      ch[stream] ||= ''
+      ch[stream] << out
+      if out[-1..-1] == "\n"
+        default_io_proc ch, stream, ch[stream]
+        ch[stream] = ''
+      end
+    end
+
     # The configuration instance associated with this actor.
     attr_reader :configuration
 
@@ -201,7 +210,7 @@
     #
     # If +pretend+ mode is active, this does nothing.
     def run(cmd, options={}, &block)
-      block ||= default_io_proc
+      block ||= options[:per_line_output] ? per_line_output_proc : 
default_io_proc
       logger.debug "executing #{cmd.strip.inspect}"
 
       execute_on_servers(options) do |servers|
@@ -272,7 +281,7 @@
     #
     #   set :sudo, "/opt/local/bin/sudo"
     def sudo(command, options={}, &block)
-      block ||= default_io_proc
+      block ||= options[:per_line_output] ? per_line_output_proc : 
default_io_proc
 
       # in order to prevent _each host_ from prompting when the password was
       # wrong, let's track which host prompted first and only allow subsequent

Reply via email to