[Groonga-commit] droonga/droonga-http-server at 5032e5d [master] Use promptly more correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 18 19:41:13 JST 2014


YUKI Hiroshi	2014-09-18 19:41:13 +0900 (Thu, 18 Sep 2014)

  New Revision: 5032e5d4cbd9ef1140fe1b5b214bb6832863d05d
  https://github.com/droonga/droonga-http-server/commit/5032e5d4cbd9ef1140fe1b5b214bb6832863d05d

  Message:
    Use promptly more correctly

  Modified files:
    bin/droonga-http-server-configure

  Modified: bin/droonga-http-server-configure (+25 -26)
===================================================================
--- bin/droonga-http-server-configure    2014-09-18 19:40:54 +0900 (de2a591)
+++ bin/droonga-http-server-configure    2014-09-18 19:41:13 +0900 (94bb0d2)
@@ -73,9 +73,11 @@ function ensureServiceStopped(callback) {
 
   console.log('The droonga-http-server service is now running.');
   console.log('Before reconfiguration, the service is going to be stopped.');
-  promptly.confirm('Are you sure you want to continue reconfiguration? (y/N)',
+  promptly.confirm('Are you sure you want to continue reconfiguration? (y/N): ',
+                   { default: 'no',
+                     retry:   false },
                    function(error, ok) {
-                     if (!ok)
+                     if (error || !ok)
                        return process.exit(false);
                      stopService(callback);
                    });
@@ -131,28 +133,19 @@ function configFileExists() {
 function confirmToReconfigure(callback) {
   if (!options.quiet && !options.resetConfig) {
     promptly.confirm('Do you want the configuration file ' +
-                        '\"droonga-http-server.yaml\" to be regenerated?',
-                      function(ok) {
-                        options.resetConfig = ok;
-                        callback();
-                      });
+                        '\"droonga-http-server.yaml\" to be regenerated? (y/N): ',
+                     { default: 'no',
+                       retry:   false },
+                     function(error, ok) {
+                       options.resetConfig = !error && ok;
+                       callback();
+                     });
   }
   else {
     callback();
   }
 }
 
-function input(message, defaultValue, callback) {
-  promptly.prompt(message,
-                  function(value) {
-                    value = value.trim();
-                    if (value === '')
-                      value = defaultValue;
-                    callback(value);
-                  });
-}
-
-
 var configValues = {};
 
 function setValue(name, message, callback) {
@@ -161,10 +154,13 @@ function setValue(name, message, callback) {
     callback();
   }
   else {
-    input(message, options[name], function(value) {
-      configValues[name] = value;
-      callback();
-    });
+    promptly.prompt(message + ' [' + options[name] + ']: ',
+                    { default: options[name],
+                      retry:   false },
+                    function(error, value) {
+                      configValues[name] = value;
+                      callback();
+                    });
   }
 }
 
@@ -174,10 +170,13 @@ function setBoolean(name, message, callback) {
     callback();
   }
   else {
-    promptly.confirm(message, function(ok) {
-      configValues[name] = ok;
-      callback();
-    });
+    promptly.confirm(message + ' (y/N): ',
+                     { default: 'no',
+                       retry:   false },
+                     function(error, ok) {
+                       configValues[name] = !error && ok;
+                       callback();
+                     });
   }
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index