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

jesse at bestpractical.com jesse at bestpractical.com
Thu May 8 17:46:50 EDT 2008


Author: jesse
Date: Thu May  8 17:46:49 2008
New Revision: 12161

Modified:
   sd/trunk/   (props changed)
   sd/trunk/bin/sd
   sd/trunk/lib/App/SD/Model/Attachment.pm

Log:
 r30553 at 106 (orig r12113):  jesse | 2008-05-06 16:14:08 -0400
 * yay. plain text attachments wokr


Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd	(original)
+++ sd/trunk/bin/sd	Thu May  8 17:46:49 2008
@@ -14,31 +14,60 @@
 use base qw/Prophet::CLI::Command/;
 
 package App::SD::CLI::Command::Ticket::Comment;
-use base qw/App::SD::CLI::Command/;
 
 use constant record_class => 'App::SD::Model::Comment';
 
 package App::SD::CLI::Command::Ticket::Comment::Create;
 use base qw/App::SD::CLI::Command::Ticket::Comment Prophet::CLI::Command::Create/;
 
-# override args to feed in that ticket's uuid as an argument to the comment
-sub args {
+sub run {
     my $self = shift;
-    return { %{$self->SUPER::args}, ticket => $self->uuid};
+    $self->args->{'ticket'} = $self->uuid;
+    $self->SUPER::run(@_);
 }
+# override args to feed in that ticket's uuid as an argument to the comment
 
+package App::SD::CLI::Command::Attachment;
+use constant record_class => 'App::SD::Model::Attachment';
 
-package App::SD::CLI::Command::Ticket::Attachment::Create;
-use base qw/App::SD::CLI::Command::Ticket::Attachment Prophet::CLI::Command::Create/;
+package App::SD::CLI::Command::Attachment::Create;
+use base qw/App::SD::CLI::Command::Attachment Prophet::CLI::Command::Create/;
+use Path::Class;
 
-# override args to feed in that ticket's uuid as an argument to the comment
-sub args {
+sub run {
     my $self = shift;
-    return { %{$self->SUPER::args}, ticket => $self->uuid};
+
+    if  (my $file = file(delete $self->args->{'file'})) {
+        $self->args->{'tricksy'} = 'abc';
+        $self->args->{'content'} = $file->slurp();
+        $self->args->{'name'} = $file->basename;
+    }
+
+    $self->SUPER::run(@_);
+
 }
 
+package App::SD::CLI::Command::Ticket::Attachment::Create;
+use base qw/App::SD::CLI::Command::Attachment::Create/;
+# override args to feed in that ticket's uuid as an argument to the comment
+#
+
 
+sub run {
+    my $self = shift;
+    $self->args->{'ticket'} = $self->uuid;
+    $self->SUPER::run(@_);
+}
 
+package App::SD::CLI::Command::Attachment::Content;
+use base qw/App::SD::CLI::Command::Attachment App::SD::CLI::Command Prophet::CLI::Command::Show/;
+
+sub run {
+    my $self = shift;
+    my $record =  $self->_get_record;
+    $record->load(uuid => $self->cli->uuid);
+    print $record->prop('content') ."\n";
+}
 
 package App::SD::CLI::Command::Help;
 use base qw/App::SD::CLI::Command/;
@@ -61,14 +90,9 @@
 
 }
 
-
 package App::SD::CLI::Command::Ticket::Show;
 use base qw/App::SD::CLI::Command Prophet::CLI::Command::Show/;
 
-
-
-
-
 package App::SD::CLI::Command::Details;
 use base qw/App::SD::CLI::Command/;
 sub run {

Modified: sd/trunk/lib/App/SD/Model/Attachment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Attachment.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Attachment.pm	Thu May  8 17:46:49 2008
@@ -16,7 +16,10 @@
 sub create {
     my $self = shift;
     my %args = validate( @_,  {props => 1});
-    
+
+
+    return (0,"You can't create an attachment without specifying a 'ticket' uuid") unless ($args{'props'}->{'ticket'});
+
     $args{'props'}->{'content_type'} ||=  'text/plain'; # XXX TODO use real mime typing;
     
 



More information about the Bps-public-commit mailing list