[Bps-public-commit] r12211 - in sd/trunk: .
sartak at bestpractical.com
sartak at bestpractical.com
Fri May 9 22:52:00 EDT 2008
Author: sartak
Date: Fri May 9 22:51:59 2008
New Revision: 12211
Modified:
sd/trunk/ (props changed)
sd/trunk/bin/sd
Log:
r55518 at onn: sartak | 2008-05-09 22:51:33 -0400
Move the "read content from --file or --content or --editor or stdin" upwards, have both comment and attachment creation use it
Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd (original)
+++ sd/trunk/bin/sd Fri May 9 22:51:59 2008
@@ -12,8 +12,32 @@
package App::SD::CLI::Command;
use base qw/Prophet::CLI::Command/;
+use Path::Class;
+
+sub get_content {
+ my $self = shift;
+ my $type = shift;
+
+ my $content;
+ if (my $file = file(delete $self->args->{'file'})) {
+ $content = $file->slurp();
+ $self->args->{'name'} = $file->basename;
+ } elsif ($content = delete $self->args->{'content'}) {
+
+ } elsif (exists $self->args->{'edit'}) {
+ require Proc::InvokeEditor;
+ $content = Proc::InvokeEditor->edit;
+ } else {
+ print "Please type your $type and press ctrl-d.\n";
+ $content = do { local $/; <> };
+ }
+
+ chomp $content;
+ return $content;
+}
package App::SD::CLI::Command::Ticket::Comment;
+use base qw/App::SD::CLI::Command::Ticket/;
use constant record_class => 'App::SD::Model::Comment';
@@ -23,6 +47,7 @@
sub run {
my $self = shift;
$self->args->{'ticket'} = $self->uuid;
+ $self->args->{'content'} = $self->get_content('comment');
$self->SUPER::run(@_);
}
# override args to feed in that ticket's uuid as an argument to the comment
@@ -30,31 +55,16 @@
package App::SD::CLI::Command::Attachment;
+use base qw/App::SD::CLI::Command/;
use constant record_class => 'App::SD::Model::Attachment';
package App::SD::CLI::Command::Attachment::Create;
use base qw/App::SD::CLI::Command::Attachment Prophet::CLI::Command::Create/;
-use Path::Class;
sub run {
my $self = shift;
- my $content;
- if (my $file = file(delete $self->args->{'file'})) {
- $content = $file->slurp();
- $self->args->{'name'} = $file->basename;
- } elsif ($content = delete $self->args->{'content'}) {
-
- } 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->args->{'content'} = $self->get_content('attachment');
$self->SUPER::run(@_);
More information about the Bps-public-commit
mailing list