Navigation Menu

Skip to content

Commit

Permalink
Register version, usage, and options in specific order
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 6, 2012
1 parent c4c93e5 commit d0d6988
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/command-line.js
Expand Up @@ -12,12 +12,7 @@ var defaultPrivilegedRanges =

function CommandLineInterface() {
this.program = program;
this.program
.version(version)
.option('--database-path <path>',
'database path [' + defaultDatabasePath + ']',
String,
defaultDatabasePath);
this.reservedOperations = [];
}
CommandLineInterface.prototype = {
get databasePath() {
Expand All @@ -36,15 +31,26 @@ CommandLineInterface.prototype = {
},

parse: function() {
this.program.version(version);
this.reservedOperations.forEach(function(operation) {
this.program[operation.method].apply(this.program, operation.arguments);
}, this);
this.program
.option('--database-path <path>',
'database path [' + defaultDatabasePath + ']',
String,
defaultDatabasePath);
this.program.parse(process.argv);
return this;
},
usage: function() {
this.program.option.apply(this.program, arguments);
this.reservedOperations.push({ method: 'usage',
arguments: arguments });
return this;
},
option: function() {
this.program.option.apply(this.program, arguments);
this.reservedOperations.push({ method: 'option',
arguments: arguments });
return this;
},

Expand Down

0 comments on commit d0d6988

Please sign in to comment.