[Bps-public-commit] r12177 - in sd/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Thu May 8 20:37:48 EDT 2008


Author: sartak
Date: Thu May  8 20:37:45 2008
New Revision: 12177

Modified:
   sd/trunk/   (props changed)
   sd/trunk/bin/sd

Log:
 r55474 at onn:  sartak | 2008-05-08 20:37:39 -0400
 Allow ./bin/sd ticket attachment --edit to open an editor. If neither --edit nor --file are passed in, read from STDIN.


Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd	(original)
+++ sd/trunk/bin/sd	Thu May  8 20:37:45 2008
@@ -39,12 +39,22 @@
 sub run {
     my $self = shift;
 
-    if  (my $file = file(delete $self->args->{'file'})) {
-        my $content = $file->slurp();
-        chomp $content;
-        $self->args->{'content'} = $content;
+    my $content;
+    if (my $file = file(delete $self->args->{'file'})) {
+        $content = $file->slurp();
         $self->args->{'name'} = $file->basename;
     }
+    elsif (exists $self->args->{'edit'}) {
+        require Proc::InvokeEditor;
+        $content = Proc::InvokeEditor->edit;
+    }
+    else {
+        print "Please type your comment and press ctrl-d.\n";
+        $content = do { local $/; <> };
+    }
+
+    chomp $content;
+    $self->args->{'content'} = $content;
 
     $self->SUPER::run(@_);
 



More information about the Bps-public-commit mailing list