YUKI Hiroshi
null+****@clear*****
Thu Sep 18 18:22:10 JST 2014
YUKI Hiroshi 2014-09-18 18:22:10 +0900 (Thu, 18 Sep 2014) New Revision: 0c7611f85f81493f3d7ca57e03ede5b1c094cd82 https://github.com/droonga/droonga-http-server/commit/0c7611f85f81493f3d7ca57e03ede5b1c094cd82 Message: Set "*Given" flags for command line options Modified files: lib/server-options.js Modified: lib/server-options.js (+78 -29) =================================================================== --- lib/server-options.js 2014-09-18 18:01:12 +0900 (3554c17) +++ lib/server-options.js 2014-09-18 18:22:10 +0900 (58d073d) @@ -19,16 +19,27 @@ options.tag = defaultConfigs.engine.tag; options.defaultDataset = defaultConfigs.engine.default_dataset; options.receiverHostName = defaultConfigs.engine.receiver_host; -intOption = function(newValue, oldValue) { +function intOption(newValue, oldValue) { return parseInt(newValue); } -pluginsOption = function(newValue, oldValue) { +function pluginsOption(newValue, oldValue) { return newValue.split(/\s*,\s*/).map(function (plugin) { return require(plugin); }); } +function generateOptionHandler(onHandle, converter) { + return function(newValue, oldValue) { + onHandle(newValue); + if (handler) + return converter(newValue); + else + return newValue; + }; +} + + options = options .version(version); @@ -40,46 +51,84 @@ exports.add = add; function define() { add('--port <port>', - 'Port number (' + options.port + ')', - intOption); + 'Port number (' + options.port + ')', + generateOptionHandler(function() { + options.portGiven = true; + }, intOption)); add('--receive-host-name <name>', - 'Host name of the protocol adapter. ' + - 'It must be resolvable by Droonga engine. ' + - '(' + options.receiverHostName + ')'); + 'Host name of the protocol adapter. ' + + 'It must be resolvable by Droonga engine. ' + + '(' + options.receiverHostName + ')', + generateOptionHandler(function() { + options.receiveHostNameGiven = true; + })); add('--droonga-engine-host-name <name>', - 'Host name of Droonga engine (' + options.droongaEngineHostName + ')'); + 'Host name of Droonga engine (' + options.droongaEngineHostName + ')', + generateOptionHandler(function() { + options.droongaEngineHostNameGiven = true; + })); add('--droonga-engine-port <port>', - 'Port number of Droonga engine (' + options.droongaEnginePort + ')', - intOption); + 'Port number of Droonga engine (' + options.droongaEnginePort + ')', + generateOptionHandler(function() { + options.droongaEnginePortGiven = true; + }, intOption)); add('--default-dataset <dataset>', - 'The default dataset (' + options.defaultDataset + ')'); + 'The default dataset (' + options.defaultDataset + ')', + generateOptionHandler(function() { + options.defaultDatasetGiven = true; + })); add('--tag <tag>', - 'The tag (' + options.tag + ')'); + 'The tag (' + options.tag + ')', + generateOptionHandler(function() { + options.tagGiven = true; + })); add('--access-log-file <file>', - 'Output access logs to <file>. ' + - 'You can use "-" as <file> to output to the standard output. ' + - '(' + options.accessLogFile + ')'); + 'Output access logs to <file>. ' + + 'You can use "-" as <file> to output to the standard output. ' + + '(' + options.accessLogFile + ')', + generateOptionHandler(function() { + options.accessLogFileGiven = true; + })); add('--system-log-file <file>', - 'Output system logs to <file>. ' + - 'You can use "-" as <file> to output to the standard output. ' + - '(' + options.systemLogFile + ')'); + 'Output system logs to <file>. ' + + 'You can use "-" as <file> to output to the standard output. ' + + '(' + options.systemLogFile + ')', + generateOptionHandler(function() { + options.systemLogFileGiven = true; + })); add('--cache-size <size>', - 'The max number of cached requests ' + - '(' + options.cacheSize + ')', - intOption); + 'The max number of cached requests ' + + '(' + options.cacheSize + ')', + generateOptionHandler(function() { + options.cacheSizeGiven = true; + }, intOption)); add('--enable-trust-proxy', - 'Enable "trust proxy" configuration. It is required when you run droonga-http-server behind a reverse proxy. ' + - '(' + options.enableTrustProxy + ')'); + 'Enable "trust proxy" configuration. It is required when you run droonga-http-server behind a reverse proxy. ' + + '(' + options.enableTrustProxy + ')', + generateOptionHandler(function() { + options.enableTrustProxyGiven = true; + })); add('--plugins <plugin1,plugin2,...>', - 'Use specified plugins. ' + - '(' + options.plugins.join(',') + ')', - pluginsOption); + 'Use specified plugins. ' + + '(' + options.plugins.join(',') + ')', + generateOptionHandler(function() { + options.pluginsGiven = true; + }, pluginsOption)); add('--daemon', - 'Run as a daemon. (' + options.daemon + ')'); + 'Run as a daemon. (' + options.daemon + ')', + generateOptionHandler(function() { + options.daemonGiven = true; + })); add('--pid-file <pid-file>', - 'Output PID to <pid-file>.'); + 'Output PID to <pid-file>.', + generateOptionHandler(function() { + options.pidFileGiven = true; + })); add('--environment <environment>', - 'Use specified environment. (' + options.environment + ')'); + 'Use specified environment. (' + options.environment + ')', + generateOptionHandler(function() { + options.environmentGiven = true; + })); return exports; } exports.define = define; -------------- next part -------------- HTML����������������������������...Download