[Bps-public-commit] r13933 - in sd/trunk: . lib/App/SD/CLI lib/App/SD/CLI/Command lib/App/SD/CLI/Command/Attachment lib/App/SD/CLI/Command/Ticket lib/App/SD/CLI/Command/Ticket/Attachment lib/App/SD/CLI/Command/Ticket/Comment lib/App/SD/CLI/Model

sartak at bestpractical.com sartak at bestpractical.com
Wed Jul 9 17:35:22 EDT 2008


Author: sartak
Date: Wed Jul  9 17:35:22 2008
New Revision: 13933

Added:
   sd/trunk/lib/App/SD/CLI/
   sd/trunk/lib/App/SD/CLI/Command/
   sd/trunk/lib/App/SD/CLI/Command.pm
   sd/trunk/lib/App/SD/CLI/Command/Attachment/
   sd/trunk/lib/App/SD/CLI/Command/Attachment/Content.pm
   sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Details.pm
   sd/trunk/lib/App/SD/CLI/Command/Help.pm
   sd/trunk/lib/App/SD/CLI/Command/Merge.pm
   sd/trunk/lib/App/SD/CLI/Command/Pull.pm
   sd/trunk/lib/App/SD/CLI/Command/Push.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Search.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
   sd/trunk/lib/App/SD/CLI/Model/
   sd/trunk/lib/App/SD/CLI/Model/Attachment.pm
   sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
   sd/trunk/lib/App/SD/CLI/Model/TicketComment.pm
Modified:
   sd/trunk/   (props changed)
   sd/trunk/bin/sd

Log:
 r63991 at onn:  sartak | 2008-07-09 17:34:31 -0400
 Explode bin/sd into App/SD/CLI


Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd	(original)
+++ sd/trunk/bin/sd	Wed Jul  9 17:35:22 2008
@@ -5,244 +5,9 @@
 $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} || $ENV{'HOME'}.'/.sd';
 use Prophet::CLI;
 use App::SD;
-use App::SD::Model::Ticket;
 
-package App::SD::CLI::Command;
-use Moose::Role;
-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'}) {
-        $content = $self->edit_text('');
-    } else {
-        print "Please type your $type and press ctrl-d.\n";
-        $content = do { local $/; <> };
-    }
-
-    chomp $content;
-    return $content;
-}
-
-package App::SD::CLI::Model::Ticket;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Ticket';
-
-package App::SD::CLI::Model::TicketComment;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Comment';
-
-package App::SD::CLI::Model::Attachment;
-use Moose::Role;
-use constant record_class => 'App::SD::Model::Attachment';
-
-
-
-
-
-package App::SD::CLI::Command::Ticket::Comment::Create;
-use Moose;
-
-extends 'Prophet::CLI::Command::Create';
-with 'App::SD::CLI::Model::TicketComment';
-with 'App::SD::CLI::Command';
-
-override run => sub  {
-    my $self = shift;
-    $self->args->{'ticket'} = $self->cli->uuid;
-    $self->args->{'content'} = $self->get_content('comment');
-    super(@_);
-};
-# override args to feed in that ticket's uuid as an argument to the comment
-
-
-
-package App::SD::CLI::Command::Attachment::Create;
-use Moose;
-extends 'Prophet::CLI::Command::Create';
-with 'App::SD::CLI::Model::Attachment';
-with 'App::SD::CLI::Command';
-
-override run => sub {
-    my $self = shift;
-    $self->args->{'content'} = $self->get_content('attachment');
-    super(@_);
-
-};
-
-package App::SD::CLI::Command::Ticket::Attachment::Create;
-use Moose;
-extends 'App::SD::CLI::Command::Attachment::Create';
-# override args to feed in that ticket's uuid as an argument to the comment
-
-override run => sub  {
-    my $self = shift;
-    $self->args->{'ticket'} = $self->cli->uuid;
-    super(@_);
-};
-
-
-package App::SD::CLI::Command::Ticket::Attachment::Search;
-use Moose;
-extends 'Prophet::CLI::Command::Search';
-with 'Prophet::CLI::RecordCommand';
-with 'App::SD::CLI::Model::Attachment';
-# override args to feed in that ticket's uuid as an argument to the comment
-
-
-sub type {'attachment'}
-sub get_search_callback {
-    my $self = shift;
-    return sub {
-        shift->prop('ticket') eq $self->uuid ? 1 : 0;
-        }
-
-}
-
-
-package App::SD::CLI::Command::Attachment::Content;
-use Moose;
-extends 'Prophet::CLI::Command::Show';
-with 'App::SD::CLI::Model::Attachment';
-with 'App::SD::CLI::Command';
-
-sub run {
-    my $self = shift;
-    my $record =  $self->_get_record_class;
-    $record->load(uuid => $self->cli->uuid);
-    print $record->prop('content');
-}
-
-package App::SD::CLI::Command::Help;
-use Moose; 
-extends 'Prophet::CLI::Command';
-with 'App::SD::CLI::Command';
-
-sub run {
-
-print <<EOF
-$0 @{[$App::SD::VERSION]}
-
-$0 ticket create --summary "This is a summary" --status new --somekey value
-$0 ticket update --uuid <uuid> --status resolved
-$0 ticket search --regex .
-$0 ticket delete --uuid <uuid>
-$0 ticket show --uuid <uuid>
-$0 pull --from remote-url
-
-
-$0 help  
-    Show this file
-
-= ENVIRONMENT
-
-  export SD_REPO=/path/to/sd/replica
-  # Specify where the ticket database SD is using should reside
-
-= EXAMPLES
-
-    sd pull --from rt:http://rt3.fsck.com|QUEUENAME|QUERY
-
-EOF
-
-}
-
-package App::SD::CLI::Command::Ticket::Show;
-use Moose;
-extends 'Prophet::CLI::Command::Show';
-with 'App::SD::CLI::Command';
-with 'App::SD::CLI::Model::Ticket';
-
-package App::SD::CLI::Command::Details;
-use Moose;
-with 'App::SD::CLI::Command';
-with 'App::SD::CLI::Model::Ticket';
-
-sub run {
-    my $self = shift;
-    print "\n=head1 METADATA\n\n"; 
-    $self->App::SD::CLI::Command::Ticket::Show::run();
-    print "\n=head1 ATTACHMENTS\n\n";
-    use Clone;
-    my $foo = Clone::clone($self);
-    $foo->type('attachment');
-    bless $foo, 'App::SD::CLI::Command::Ticket::Attachment::Search';
-    $foo->run;
-    print "\n=head1 COMMENTS\n\n";
-    my $bar = Clone::clone($self);
-    bless $bar, 'App::SD::CLI::Command::Ticket::Comments';
-    $bar->type('comment');
-    $bar->App::SD::CLI::Command::Ticket::Comments::run();
-}
-
-package App::SD::CLI::Command::Ticket::Comments;
-use Moose;
-extends 'Prophet::CLI::Command';
-with 'Prophet::CLI::RecordCommand';
-with 'App::SD::CLI::Model::Ticket';
-
-sub run {
-    my $self = shift;
-    my $record = $self->_get_record_class();
-    $record->load( uuid => $self->uuid );
-    unless (@{$record->comments}) {
-        print "No comments found\n";
-    }
-
-    for (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
-        print "id: ".$_->luid." (".$_->uuid.")\n";
-        print "date: ".$_->prop('date')."\n";
-        print $_->prop('content')."\n";
-    }
-
-}
-
-
-package App::SD::CLI::Command::Merge;
-use Moose;
-extends qw/Prophet::CLI::Command::Merge/;
-with 'App::SD::CLI::Command';
-
-package App::SD::CLI::Command::Push;
-use Moose;
-extends qw/App::SD::CLI::Command::Merge/;
-
-sub run {
-    my $self = shift; 
-    local $ENV{PROPHET_RESOLVER} = 'Prompt';
-    bless $self, 'App::SD::CLI::Command::Merge';
-    $self->args( {to => $self->args->{'to'}, from => $self->app_handle->default_replica_type.":file://".$self->app_handle->handle->fs_root });
-    $self->run; 
-}
-
-package App::SD::CLI::Command::Pull;
-use Moose; 
-extends qw/App::SD::CLI::Command::Merge/;
-
-sub run {
-    my $self = shift; 
-
-    die "Please specify a --from.\n" if !defined($self->args->{'from'});
-
-    local $ENV{PROPHET_RESOLVER} = 'Prompt';
-    bless $self, 'App::SD::CLI::Command::Merge';
-    $self->args({  from => $self->args->{'from'}, 
-                   to => $self->cli->app_handle->default_replica_type.":file://".$self->cli->app_handle->handle->fs_root });
-    $self->run; 
-}
-
-package main;
-
-my $cli = Prophet::CLI->new( { app_class => 'App::SD' } );
+my $cli = Prophet::CLI->new({ app_class => 'App::SD' });
 $cli->run_one_command;
 
-
 1;
+

Added: sd/trunk/lib/App/SD/CLI/Command.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,27 @@
+package App::SD::CLI::Command;
+use Moose::Role;
+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'}) {
+        $content = $self->edit_text('');
+    } else {
+        print "Please type your $type and press ctrl-d.\n";
+        $content = do { local $/; <> };
+    }
+
+    chomp $content;
+    return $content;
+}
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Attachment/Content.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Attachment/Content.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,18 @@
+package App::SD::CLI::Command::Attachment::Content;
+use Moose;
+extends 'Prophet::CLI::Command::Show';
+with 'App::SD::CLI::Model::Attachment';
+with 'App::SD::CLI::Command';
+
+sub run {
+    my $self = shift;
+    my $record =  $self->_get_record_class;
+    $record->load(uuid => $self->cli->uuid);
+    print $record->prop('content');
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Attachment/Create.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,18 @@
+package App::SD::CLI::Command::Attachment::Create;
+use Moose;
+extends 'Prophet::CLI::Command::Create';
+with 'App::SD::CLI::Model::Attachment';
+with 'App::SD::CLI::Command';
+
+override run => sub {
+    my $self = shift;
+    $self->args->{'content'} = $self->get_content('attachment');
+    super(@_);
+
+};
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Details.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Details.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,31 @@
+package App::SD::CLI::Command::Details;
+use Moose;
+with 'App::SD::CLI::Command';
+with 'App::SD::CLI::Model::Ticket';
+
+use App::SD::CLI::Command::Ticket::Show;
+use App::SD::CLI::Command::Ticket::Attachment::Search;
+use App::SD::CLI::Command::Ticket::Comments;
+
+sub run {
+    my $self = shift;
+    print "\n=head1 METADATA\n\n";
+    $self->App::SD::CLI::Command::Ticket::Show::run();
+
+    print "\n=head1 ATTACHMENTS\n\n";
+    use Clone;
+    my $foo = Clone::clone($self);
+    $foo->type('attachment');
+    bless $foo, 'App::SD::CLI::Command::Ticket::Attachment::Search';
+    $foo->run;
+
+    print "\n=head1 COMMENTS\n\n";
+    my $bar = Clone::clone($self);
+    bless $bar, 'App::SD::CLI::Command::Ticket::Comments';
+    $bar->type('comment');
+    $bar->App::SD::CLI::Command::Ticket::Comments::run();
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Help.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Help.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,39 @@
+package App::SD::CLI::Command::Help;
+use Moose;
+extends 'Prophet::CLI::Command';
+with 'App::SD::CLI::Command';
+
+sub run {
+
+print <<EOF
+$0 @{[$App::SD::VERSION]}
+
+$0 ticket create --summary "This is a summary" --status new --somekey value
+$0 ticket update --uuid <uuid> --status resolved
+$0 ticket search --regex .
+$0 ticket delete --uuid <uuid>
+$0 ticket show --uuid <uuid>
+$0 pull --from remote-url
+
+
+$0 help
+    Show this file
+
+= ENVIRONMENT
+
+  export SD_REPO=/path/to/sd/replica
+  # Specify where the ticket database SD is using should reside
+
+= EXAMPLES
+
+    sd pull --from rt:http://rt3.fsck.com|QUEUENAME|QUERY
+
+EOF
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Merge.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Merge.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,10 @@
+package App::SD::CLI::Command::Merge;
+use Moose;
+extends qw/Prophet::CLI::Command::Merge/;
+with 'App::SD::CLI::Command';
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Pull.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Pull.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,21 @@
+package App::SD::CLI::Command::Pull;
+use Moose;
+extends qw/App::SD::CLI::Command::Merge/;
+
+sub run {
+    my $self = shift;
+
+    die "Please specify a --from.\n" if !defined($self->args->{'from'});
+
+    local $ENV{PROPHET_RESOLVER} = 'Prompt';
+    bless $self, 'App::SD::CLI::Command::Merge';
+    $self->args({  from => $self->args->{'from'},
+                   to => $self->cli->app_handle->default_replica_type.":file://".$self->cli->app_handle->handle->fs_root });
+    $self->run;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Push.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Push.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,17 @@
+package App::SD::CLI::Command::Push;
+use Moose;
+extends qw/App::SD::CLI::Command::Merge/;
+
+sub run {
+    my $self = shift;
+    local $ENV{PROPHET_RESOLVER} = 'Prompt';
+    bless $self, 'App::SD::CLI::Command::Merge';
+    $self->args( {to => $self->args->{'to'}, from => $self->app_handle->default_replica_type.":file://".$self->app_handle->handle->fs_root });
+    $self->run;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,16 @@
+package App::SD::CLI::Command::Ticket::Attachment::Create;
+use Moose;
+extends 'App::SD::CLI::Command::Attachment::Create';
+# override args to feed in that ticket's uuid as an argument to the comment
+
+override run => sub  {
+    my $self = shift;
+    $self->args->{'ticket'} = $self->cli->uuid;
+    super(@_);
+};
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Search.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Search.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,22 @@
+package App::SD::CLI::Command::Ticket::Attachment::Search;
+use Moose;
+extends 'Prophet::CLI::Command::Search';
+with 'Prophet::CLI::RecordCommand';
+with 'App::SD::CLI::Model::Attachment';
+# override args to feed in that ticket's uuid as an argument to the comment
+
+
+sub type {'attachment'}
+sub get_search_callback {
+    my $self = shift;
+    return sub {
+        shift->prop('ticket') eq $self->uuid ? 1 : 0;
+        }
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,20 @@
+package App::SD::CLI::Command::Ticket::Comment::Create;
+use Moose;
+
+extends 'Prophet::CLI::Command::Create';
+with 'App::SD::CLI::Model::TicketComment';
+with 'App::SD::CLI::Command';
+
+# override args to feed in that ticket's uuid as an argument to the comment
+override run => sub {
+    my $self = shift;
+    $self->args->{'ticket'} = $self->cli->uuid;
+    $self->args->{'content'} = $self->get_content('comment');
+    super(@_);
+};
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,27 @@
+package App::SD::CLI::Command::Ticket::Comments;
+use Moose;
+extends 'Prophet::CLI::Command';
+with 'Prophet::CLI::RecordCommand';
+with 'App::SD::CLI::Model::Ticket';
+
+sub run {
+    my $self = shift;
+    my $record = $self->_get_record_class();
+    $record->load( uuid => $self->uuid );
+    unless (@{$record->comments}) {
+        print "No comments found\n";
+    }
+
+    for (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
+        print "id: ".$_->luid." (".$_->uuid.")\n";
+        print "date: ".$_->prop('date')."\n";
+        print $_->prop('content')."\n";
+    }
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,10 @@
+package App::SD::CLI::Command::Ticket::Show;
+use Moose;
+extends 'Prophet::CLI::Command::Show';
+with 'App::SD::CLI::Command';
+with 'App::SD::CLI::Model::Ticket';
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Model/Attachment.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Model/Attachment.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,9 @@
+package App::SD::CLI::Model::Attachment;
+use Moose::Role;
+
+use constant record_class => 'App::SD::Model::Attachment';
+
+no Moose::Role;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Model/Ticket.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,9 @@
+package App::SD::CLI::Model::Ticket;
+use Moose::Role;
+
+use constant record_class => 'App::SD::Model::Ticket';
+
+no Moose::Role;
+
+1;
+

Added: sd/trunk/lib/App/SD/CLI/Model/TicketComment.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Model/TicketComment.pm	Wed Jul  9 17:35:22 2008
@@ -0,0 +1,9 @@
+package App::SD::CLI::Model::TicketComment;
+use Moose::Role;
+
+use constant record_class => 'App::SD::Model::Comment';
+
+no Moose::Role;
+
+1;
+



More information about the Bps-public-commit mailing list