[Bps-public-commit] SD branch, master, updated. b182620ae89fedce08fb12151aaeeeb20c3da053

spang at bestpractical.com spang at bestpractical.com
Mon Aug 24 13:57:30 EDT 2009


The branch, master has been updated
       via  b182620ae89fedce08fb12151aaeeeb20c3da053 (commit)
       via  3ca1bc96cdb3a204880414dab2dbedc26696202a (commit)
       via  31b9e47939323ed14123ff90d6bb269593a5662d (commit)
       via  f3c6ac313c3f948bfb5043250ed0ea981cbee945 (commit)
      from  2929b6cba268e349d9d62f9d46db49388e94e8fa (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Clone.pm         |   13 +++++++++++++
 lib/App/SD/CLI/Command/Init.pm          |   13 +++++++++++++
 lib/App/SD/CLI/Command/Ticket/Search.pm |   12 ++++++------
 lib/App/SD/CLI/Model/Ticket.pm          |   29 ++++++++++++++++++++++++-----
 lib/App/SD/CLI/NewReplicaCommand.pm     |   16 +++++++++++-----
 lib/App/SD/Record.pm                    |    3 +--
 t/sd-usage.t                            |   22 +++++++++++++++++++++-
 7 files changed, 89 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit f3c6ac313c3f948bfb5043250ed0ea981cbee945
Author: Christine Spang <spang at bestpractical.com>
Date:   Sat Aug 22 14:53:33 2009 +0100

    Update usage messages for init/clone --non-interactive
    
    Closes: 49bcc92f-8dab-11de-820f-a0a7844892fa

diff --git a/lib/App/SD/CLI/Command/Clone.pm b/lib/App/SD/CLI/Command/Clone.pm
index d7c10c9..82e359d 100644
--- a/lib/App/SD/CLI/Command/Clone.pm
+++ b/lib/App/SD/CLI/Command/Clone.pm
@@ -8,6 +8,19 @@ sub ARG_TRANSLATIONS {
     n => 'non-interactive',
 };
 
+sub usage_msg {
+    my $self = shift;
+    my $cmd = $self->cli->get_script_name;
+
+    return <<"END_USAGE";
+usage: ${cmd}clone --from <url> [--non-interactive]
+
+Options:
+    -n | --non-interactive - Don't prompt to specify email address for new
+                             database
+END_USAGE
+}
+
 override run => sub {
     my $self = shift;
 
diff --git a/lib/App/SD/CLI/Command/Init.pm b/lib/App/SD/CLI/Command/Init.pm
index e28e75d..71b8e0d 100644
--- a/lib/App/SD/CLI/Command/Init.pm
+++ b/lib/App/SD/CLI/Command/Init.pm
@@ -3,6 +3,19 @@ use Any::Moose;
 extends 'Prophet::CLI::Command::Init';
 with 'App::SD::CLI::NewReplicaCommand';
 
+sub usage_msg {
+    my $self = shift;
+    my $cmd = $self->cli->get_script_name;
+
+    return <<"END_USAGE";
+usage: ${cmd}init [--non-interactive]
+
+Options:
+    -n | --non-interactive - Don't prompt to edit settings or specify email
+                             address for new database
+END_USAGE
+}
+
 sub ARG_TRANSLATIONS {
     shift->SUPER::ARG_TRANSLATIONS(),
     n => 'non-interactive',
diff --git a/t/sd-usage.t b/t/sd-usage.t
index 5ff641c..373bc28 100644
--- a/t/sd-usage.t
+++ b/t/sd-usage.t
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Prophet::Test tests => 18;
+use Prophet::Test tests => 22;
 use App::SD::Test;
 use App::SD::CLI;
 $Prophet::Test::CLI_CLASS = 'App::SD::CLI';
@@ -86,6 +86,26 @@ my @cmds = (
         error   => [ 'usage: sd-usage.t browser [--port <number>]' ],
         comment => 'browser usage',
     },
+    {
+        cmd     => [ qw(init -h) ],
+        error   => [ 'usage: sd-usage.t init [--non-interactive]',
+            '',
+            'Options:',
+            "    -n | --non-interactive - Don't prompt to edit settings or specify email",
+            '                             address for new database',
+        ],
+        comment => 'init usage',
+    },
+    {
+        cmd     => [ qw(clone -h) ],
+        error   => [ 'usage: sd-usage.t clone --from <url> [--non-interactive]',
+            '',
+            'Options:',
+            "    -n | --non-interactive - Don't prompt to specify email address for new",
+            '                             database',
+        ],
+        comment => 'clone usage',
+    },
 );
 
 my $in_interactive_shell = 0;

commit 31b9e47939323ed14123ff90d6bb269593a5662d
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 09:29:26 2009 +0100

    PROPHET_EMAIL can contain an email address too

diff --git a/lib/App/SD/CLI/NewReplicaCommand.pm b/lib/App/SD/CLI/NewReplicaCommand.pm
index 442780c..dc90901 100644
--- a/lib/App/SD/CLI/NewReplicaCommand.pm
+++ b/lib/App/SD/CLI/NewReplicaCommand.pm
@@ -20,8 +20,13 @@ sub new_replica_wizard {
             print "\nYou need an email address configured to use SD. I'll try"
                 ." to find one.\n";
 
+            if ( $ENV{PROPHET_EMAIL} ) {
+                $self->_migrate_email_from_env( 'PROPHET_EMAIL' );
+            }
+        }
+        if ( ! defined $self->config->get( key => 'user.email-address' ) ) {
             if ( $ENV{EMAIL} ) {
-                $self->_migrate_email_from_env;
+                $self->_migrate_email_from_env( 'EMAIL' );
             }
         }
         # if we still don't have an email, ask
@@ -65,17 +70,18 @@ sub _prompt_which_config_file {
 
 sub _migrate_email_from_env {
     my $self = shift;
+    my $var = shift;
 
-    print "Found '$ENV{EMAIL}' in \$EMAIL.\n";
-    my $config_file = $self->_prompt_which_config_file( $ENV{EMAIL} );
+    print "Found '$ENV{$var}' in \$$var.\n";
+    my $config_file = $self->_prompt_which_config_file( $ENV{$var} );
 
     if ( $config_file ) {
         $self->config->set(
             key      => 'user.email-address',
-            value    => $ENV{EMAIL},
+            value    => $ENV{$var},
             filename => $config_file,
         );
-        print "  - added email '$ENV{EMAIL}' to\n    $config_file\n";
+        print "  - added email '$ENV{$var}' to\n    $config_file\n";
     }
 }
 

commit 3ca1bc96cdb3a204880414dab2dbedc26696202a
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 18:17:06 2009 +0100

    Make it obvious when a method overrides a method from the superclass

diff --git a/lib/App/SD/CLI/Command/Ticket/Search.pm b/lib/App/SD/CLI/Command/Ticket/Search.pm
index 5cdfd54..de4c776 100644
--- a/lib/App/SD/CLI/Command/Ticket/Search.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Search.pm
@@ -5,7 +5,7 @@ with 'App::SD::CLI::Command';
 
 sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(),  s => 'sort', g => 'group'  };
 
-sub usage_msg {
+override usage_msg => sub {
     my $self = shift;
     my $script = $self->cli->get_script_name;
 
@@ -21,10 +21,10 @@ sub usage_msg {
 usage: ${script}${type_and_subcmd}
        ${script}${type_and_subcmd} -- summary=~foo status!~new|open
 END_USAGE
-}
+};
 
 # frob the sort routine before running prophet's search command
-sub run {
+override run => sub {
     my $self = shift;
 
     $self->print_usage if $self->has_arg('h');
@@ -94,16 +94,16 @@ sub run {
         );
     }
     $self->SUPER::run(@_);
-}
+};
 
 # implicit status != closed
-sub default_match {
+override default_match => sub {
     my $self   = shift;
     my $ticket = shift;
 
     return 1 if $ticket->has_active_status();
     return 0;
-}
+};
 
 __PACKAGE__->meta->make_immutable;
 no Any::Moose;
diff --git a/lib/App/SD/Record.pm b/lib/App/SD/Record.pm
index c6b9c53..1c36d82 100644
--- a/lib/App/SD/Record.pm
+++ b/lib/App/SD/Record.pm
@@ -4,8 +4,7 @@ use Params::Validate;
 
 extends 'Prophet::Record';
 
-
-sub declared_props { 'created' }
+override declared_props => sub { 'created' };
 
 sub canonicalize_prop_created {
     my $self = shift;

commit b182620ae89fedce08fb12151aaeeeb20c3da053
Author: Christine Spang <spang at bestpractical.com>
Date:   Mon Aug 24 18:47:41 2009 +0100

    Wrap expected values in ticket update --verbose

diff --git a/lib/App/SD/CLI/Model/Ticket.pm b/lib/App/SD/CLI/Model/Ticket.pm
index d200c9f..05983cf 100644
--- a/lib/App/SD/CLI/Model/Ticket.pm
+++ b/lib/App/SD/CLI/Model/Ticket.pm
@@ -169,14 +169,35 @@ sub _build_kv_pairs {
         # if called with --verbose, we print descriptions and valid values for
         # props (if they exist)
         if ( $args{verbose} ) {
-            if ( my $desc = $self->app_handle->setting( label => 'prop_descriptions' )->get()->[0]->{$prop} ) {
+            if ( my $desc = $self->app_handle->setting(
+                    label => 'prop_descriptions' )->get()->[0]->{$prop} ) {
                 $string .= '# '.$desc."\n";
             }
             if ( ($args{record}->recommended_values_for_prop($prop))[0] ) {
                 my @valid_values =
                     $args{record}->recommended_values_for_prop($prop);
-                $string .= "# valid values for $prop: ".
-                    join(', ', @valid_values)."\n";
+
+                my $valid_vals_header = "# valid values for $prop:";
+                my $valid_vals_header_len = length $valid_vals_header;
+                my $line_length = $valid_vals_header_len;
+
+                $string .= $valid_vals_header;
+                for my $val (@valid_values) {
+                    $line_length += length($val) + 1; # add 1 for space char
+                    my $default_line_length
+                        = $self->config->get( key => 'core.cli-line-length' )
+                        || $self->cli->LINE_LENGTH;
+                    if ( $line_length > $default_line_length ) {
+                        $string .= "\n#";
+                        $string .= q{ } x $valid_vals_header_len;
+                        $string .= $val;
+                        $line_length = $valid_vals_header_len + length($val);
+                    }
+                    else {
+                        $string .= " $val";
+                    }
+                }
+                $string .= "\n";
             }
         }
         $string .= "$prop: ".($args{data}->{$prop} ||'') ."\n";
@@ -184,8 +205,6 @@ sub _build_kv_pairs {
     return $string;
 }
 
-
-
 =head2 parse_record_template $str
 
 Takes a string containing a ticket record consisting of prop: value pairs

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



More information about the Bps-public-commit mailing list