[Bps-public-commit] Prophet branch, master, updated. 2d7f97951e3b3a27f728f0735ed8fee72e7ede1c
spang at bestpractical.com
spang at bestpractical.com
Wed Aug 19 13:27:10 EDT 2009
The branch, master has been updated
via 2d7f97951e3b3a27f728f0735ed8fee72e7ede1c (commit)
via 133e54dede4cbfb5acbdcf23b8b65ddf2f83fc80 (commit)
via c46fa1fcf81b789e6add0f0282ccc24d5d4c5e6d (commit)
from 71b5c2c5839146ea17ba08a402522732c0ae290d (commit)
Summary of changes:
lib/Prophet/CLI/Command.pm | 35 +++++++++++++++++++++++++----------
lib/Prophet/CLI/Command/Info.pm | 14 +++++---------
lib/Prophet/CLI/Command/Init.pm | 3 +--
3 files changed, 31 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit c46fa1fcf81b789e6add0f0282ccc24d5d4c5e6d
Author: Christine Spang <spang at bestpractical.com>
Date: Tue Aug 18 17:53:36 2009 +0100
Clean up info command
diff --git a/lib/Prophet/CLI/Command/Info.pm b/lib/Prophet/CLI/Command/Info.pm
index 4d537f5..6493f65 100644
--- a/lib/Prophet/CLI/Command/Info.pm
+++ b/lib/Prophet/CLI/Command/Info.pm
@@ -18,18 +18,14 @@ sub run {
$self->print_usage if $self->has_arg('h');
- print "Working on prophet database: ".$self->handle->url." (@{[ref($self->handle)]})".$/;
- print "DB UUID: ".$self->handle->db_uuid.$/;
- print "Changesets: ".$self->handle->latest_sequence_no.$/;
-
- print "Known types: ".join(',', @{$self->handle->list_types} ).$/;
-
+ print "Prophet database: ".$self->handle->url." (@{[ref($self->handle)]})".$/;
+ print "Database UUID: ".$self->handle->db_uuid.$/;
+ print "Replica UUID: ".$self->handle->uuid.$/;
+ print "Changesets: ".$self->handle->latest_sequence_no.$/;
+ print "Known types: ".join(',', @{$self->handle->list_types} ).$/;
}
__PACKAGE__->meta->make_immutable;
no Any::Moose;
-
-
1;
-
commit 133e54dede4cbfb5acbdcf23b8b65ddf2f83fc80
Author: Christine Spang <spang at bestpractical.com>
Date: Tue Aug 18 21:07:39 2009 +0100
Generalise prompt_Yn to allow any two choices
diff --git a/lib/Prophet/CLI/Command.pm b/lib/Prophet/CLI/Command.pm
index 9de22d6..8c98227 100644
--- a/lib/Prophet/CLI/Command.pm
+++ b/lib/Prophet/CLI/Command.pm
@@ -217,6 +217,30 @@ sub edit_props {
return \%props;
}
+=head2 prompt_choices question
+
+Asks user the question and returns 0 if answer was the second choice,
+1 otherwise. (First choice is the default.)
+
+=cut
+
+sub prompt_choices {
+ my $self = shift;
+ my ($choice1, $choice2, $question) = @_;
+
+ $choice1 = uc $choice1; # default is capsed
+ $choice2 = lc $choice2; # non-default is lowercased
+
+ Prophet::CLI->end_pager();
+ print "$question [$choice1/$choice2]: ";
+
+ chomp( my $answer = <STDIN> );
+
+ Prophet::CLI->start_pager();
+
+ return $answer !~ /^$choice2$/i;
+}
+
=head2 prompt_Yn question
Asks user the question and returns true if answer was positive or false
@@ -228,16 +252,7 @@ sub prompt_Yn {
my $self = shift;
my $msg = shift;
- Prophet::CLI->end_pager();
- print "$msg [Y/n]: ";
-
- my $a = <STDIN>;
- chomp $a;
- print "\n";
- Prophet::CLI->start_pager();
-
- return 1 if $a =~ /^(|y|yes)$/i;
- return 0;
+ return $self->prompt_choices( 'y', 'n', $msg );
}
# Create a new [replica] config file section for the given replica if
commit 2d7f97951e3b3a27f728f0735ed8fee72e7ede1c
Author: Christine Spang <spang at bestpractical.com>
Date: Tue Aug 18 17:53:15 2009 +0100
Make init command die, rather than print and exit, when it fails
to initialise the repository because it already exists.
diff --git a/lib/Prophet/CLI/Command/Init.pm b/lib/Prophet/CLI/Command/Init.pm
index ff09891..04920ba 100644
--- a/lib/Prophet/CLI/Command/Init.pm
+++ b/lib/Prophet/CLI/Command/Init.pm
@@ -19,8 +19,7 @@ sub run {
$self->print_usage if $self->has_arg('h');
if ($self->app_handle->handle->replica_exists) {
- print "Your Prophet database already exists.\n";
- return;
+ die "Your Prophet database already exists.\n";
}
$self->app_handle->handle->after_initialize( sub { shift->app_handle->set_db_defaults } );
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list