null+****@clear*****
null+****@clear*****
2012年 8月 6日 (月) 17:23:57 JST
SHIMODA Hiroshi 2012-08-06 17:23:57 +0900 (Mon, 06 Aug 2012) New Revision: 4b90120314af655c48713b94ae8abe8f1148c76e https://github.com/groonga/gcs/commit/4b90120314af655c48713b94ae8abe8f1148c76e Log: Prepare command in strict order Modified files: lib/command-line.js Modified: lib/command-line.js (+13 -7) =================================================================== --- lib/command-line.js 2012-08-06 17:19:42 +0900 (9d06cdb) +++ lib/command-line.js 2012-08-06 17:23:57 +0900 (8b9c902) @@ -12,7 +12,8 @@ var defaultPrivilegedRanges = function CommandLineInterface() { this.program = program; - this.reservedOperations = []; + this.reservedUsage = null; + this.reservedOptions = []; } CommandLineInterface.prototype = { get databasePath() { @@ -32,25 +33,30 @@ CommandLineInterface.prototype = { parse: function() { this.program.version(version); - this.reservedOperations.forEach(function(operation) { - this.program[operation.method].apply(this.program, operation.arguments); + + if (this.reservedUsage) + this.program.usage.apply(this.program, this.reservedUsage); + + this.reservedOptions.forEach(function(optionArguments) { + this.program.option.apply(this.program, optionArguments); }, this); + this.program .option('--database-path <path>', 'database path [' + defaultDatabasePath + ']', String, defaultDatabasePath); + this.program.parse(process.argv); + return this; }, usage: function() { - this.reservedOperations.push({ method: 'usage', - arguments: arguments }); + this.reservedUsage = Array.prototype.slice.call(arguments, 0) return this; }, option: function() { - this.reservedOperations.push({ method: 'option', - arguments: arguments }); + this.reservedOptions.push(Array.prototype.slice.call(arguments, 0)); return this; }, -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Download