[Bps-public-commit] SD branch, master, updated. 0.70-27-g74a4b30

spang at bestpractical.com spang at bestpractical.com
Tue Sep 1 23:00:42 EDT 2009


The branch, master has been updated
       via  74a4b300904e6defe1ae2ac419d05cc9855cad5b (commit)
      from  32a70545d98457086757575596a4025816600746 (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Shell.pm |   10 ++++++++++
 lib/App/SD/CLI/Dispatcher.pm    |    5 +++++
 lib/App/SD/Test.pm              |    2 ++
 t/sd-dispatcher.t               |    8 +++++++-
 t/sd-usage.t                    |   10 +++++++++-
 5 files changed, 33 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 74a4b300904e6defe1ae2ac419d05cc9855cad5b
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Sep 1 22:37:04 2009 -0400

    Add --version / -V

diff --git a/lib/App/SD/CLI/Command/Shell.pm b/lib/App/SD/CLI/Command/Shell.pm
index d590186..781a75c 100644
--- a/lib/App/SD/CLI/Command/Shell.pm
+++ b/lib/App/SD/CLI/Command/Shell.pm
@@ -16,6 +16,16 @@ has project_name => (
     }
 );
 
+sub usage_msg {
+    my $self = shift;
+    my $cmd = $self->cli->get_script_name;
+
+    return <<"END_USAGE";
+usage: ${cmd}\[cmd]
+       ${cmd}--version | -V
+END_USAGE
+}
+
 sub preamble {
     my $self = shift;
     my @out  = (
diff --git a/lib/App/SD/CLI/Dispatcher.pm b/lib/App/SD/CLI/Dispatcher.pm
index 3a518d2..ad620af 100644
--- a/lib/App/SD/CLI/Dispatcher.pm
+++ b/lib/App/SD/CLI/Dispatcher.pm
@@ -20,6 +20,11 @@ on qr'^(?!help)' => sub {
     if ($self->context->has_arg('help')) {
         run("help $cmd", $self, @_);
     }
+    elsif ($self->context->has_arg('version')
+            || $self->context->has_arg('V') ) {
+        print "SD $App::SD::VERSION\n";
+        exit 0;
+    }
     else {
         next_rule;
     }
diff --git a/lib/App/SD/Test.pm b/lib/App/SD/Test.pm
index e6644a7..679c5d2 100644
--- a/lib/App/SD/Test.pm
+++ b/lib/App/SD/Test.pm
@@ -16,6 +16,8 @@ our @EXPORT = qw(create_ticket_ok update_ticket_ok
 delete $ENV{'PROPHET_APP_CONFIG'};
 $ENV{'EDITOR'} = '/bin/true';
 
+$Prophet::Test::CLI_CLASS = 'App::SD::CLI';
+
 our ($A, $B, $C, $D);
 
 BEGIN {
diff --git a/t/sd-dispatcher.t b/t/sd-dispatcher.t
index 9c3ffab..afe3237 100644
--- a/t/sd-dispatcher.t
+++ b/t/sd-dispatcher.t
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Prophet::Test tests => 24;
+use Prophet::Test tests => 26;
 use App::SD::Test;
 no warnings 'once';
 
@@ -209,3 +209,9 @@ run_output_matches( 'sd', [ 'ticket', 'give', 'spang at bestpractical.com' ],
     [],
     [ 'Usage: give <id> <email>' ]
 );
+
+require App::SD;
+run_output_matches( 'sd', [ '-V' ],
+    [ "SD $App::SD::VERSION" ], 'version short' );
+run_output_matches( 'sd', [ '--version' ],
+    [ "SD $App::SD::VERSION" ], 'version long' );
diff --git a/t/sd-usage.t b/t/sd-usage.t
index 373bc28..c596ffe 100644
--- a/t/sd-usage.t
+++ b/t/sd-usage.t
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Prophet::Test tests => 22;
+use Prophet::Test tests => 24;
 use App::SD::Test;
 use App::SD::CLI;
 $Prophet::Test::CLI_CLASS = 'App::SD::CLI';
@@ -106,6 +106,14 @@ my @cmds = (
         ],
         comment => 'clone usage',
     },
+    {
+        cmd     => [ qw(-h) ],
+        error   => [
+            'usage: sd-usage.t [cmd]',
+            '       sd-usage.t --version | -V',
+        ],
+        comment => 'no-command usage',
+    },
 );
 
 my $in_interactive_shell = 0;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list