[Bps-public-commit] Prophet branch, master, updated. e1e8cd066e03b6233dedd726a1f7a2b6cff449c2

spang at bestpractical.com spang at bestpractical.com
Thu Aug 6 06:17:24 EDT 2009


The branch, master has been updated
       via  e1e8cd066e03b6233dedd726a1f7a2b6cff449c2 (commit)
      from  ddbb5e2ee35db219af36b563c36cec216543d866 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Settings.pm |   31 ++++++++++++++++---------------
 lib/Prophet/CLI/Dispatcher.pm       |   19 +++++++++++++++++++
 2 files changed, 35 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit e1e8cd066e03b6233dedd726a1f7a2b6cff449c2
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Aug 6 11:16:19 2009 +0100

    Make options for the settings command consistent with those of config/aliases/etc.

diff --git a/lib/Prophet/CLI/Command/Settings.pm b/lib/Prophet/CLI/Command/Settings.pm
index fe7a0e6..61e59d3 100644
--- a/lib/Prophet/CLI/Command/Settings.pm
+++ b/lib/Prophet/CLI/Command/Settings.pm
@@ -13,9 +13,11 @@ sub usage_msg {
     my $cmd = $self->get_cmd_name;
 
     return <<"END_USAGE";
-usage: ${cmd}settings [--show]
-       ${cmd}settings [--edit]
-       ${cmd}settings --set -- setting "new value"
+usage: ${cmd}settings [show]
+       ${cmd}settings edit
+       ${cmd}settings set -- setting "new value"
+
+Note that setting values must be valid JSON.
 END_USAGE
 }
 
@@ -24,14 +26,18 @@ sub run {
 
     $self->print_usage if $self->has_arg('h');
 
+    my $settings = $self->app_handle->database_settings;
+
     my $template = $self->make_template;
 
-    if ( $self->context->has_arg('show') ) {
-        print $template. "\n";
-        return;
-    }
+    if ( $self->has_arg( 'edit' ) ) {
+        my $done = 0;
 
-    my $settings = $self->app_handle->database_settings;
+        while ( !$done ) {
+            Prophet::CLI->end_pager();
+            $done = $self->try_to_edit( template => \$template );
+        }
+    }
 
     if ( $self->context->has_arg('set') ) {
         for my $name ( $self->context->prop_names ) {
@@ -57,13 +63,8 @@ sub run {
         return;
     }
 
-    my $done = 0;
-
-    while ( !$done ) {
-        Prophet::CLI->end_pager();
-        $done = $self->try_to_edit( template => \$template );
-    }
-
+    print $template. "\n";
+    return;
 }
 
 sub make_template {
diff --git a/lib/Prophet/CLI/Dispatcher.pm b/lib/Prophet/CLI/Dispatcher.pm
index e11aea2..ccc0e41 100644
--- a/lib/Prophet/CLI/Dispatcher.pm
+++ b/lib/Prophet/CLI/Dispatcher.pm
@@ -38,6 +38,25 @@ on qr{log\s+([0-9LATEST.~]+)} => sub {
     run('log', $self);
 };
 
+under settings => sub {
+    my $self = shift;
+    on edit => sub {
+        my $self = shift;
+        $self->context->set_arg( 'edit' );
+        run('settings', $self);
+    };
+    on show => sub {
+        my $self = shift;
+        $self->context->set_arg( 'show' );
+        run('settings', $self);
+    };
+    on set => sub {
+        my $self = shift;
+        $self->context->set_arg( 'set' );
+        run('settings', $self);
+    };
+};
+
 on [ qr/^(update|edit|show|display|delete|del|rm|history)$/,
      qr/^$Prophet::CLIContext::ID_REGEX$/i ] => sub {
     my $self = shift;

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



More information about the Bps-public-commit mailing list