Navigation Menu

Skip to content

Commit

Permalink
Chain "parse()"
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 6, 2012
1 parent 9bc8ca0 commit c4c93e5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bin/cs-configure-fields
Expand Up @@ -16,9 +16,9 @@ commandLine
'The name of the domain that you are configuring. Required.',
String)
.option('--delete',
'Delete the field specified by the --name and --type options.');
'Delete the field specified by the --name and --type options.')
.parse();

commandLine.parse();
commandLine.assertHaveDomainName();
commandLine.assertDomainExists();

Expand Down
4 changes: 2 additions & 2 deletions bin/cs-create-domain
Expand Up @@ -7,9 +7,9 @@ commandLine
.usage('--domain-name <domain name> [options]')
.option('-d, --domain-name <domain name>',
'The name of the domain that you are creating. Required.',
String);
String)
.parse();

commandLine.parse();
commandLine.assertHaveDomainName();

if (commandLine.domain.exists()) {
Expand Down
5 changes: 2 additions & 3 deletions bin/cs-delete-domain
Expand Up @@ -9,9 +9,8 @@ commandLine
'The name of the domain that you are deleting. Required.',
String)
.option('-f, --force',
'Delete the domain without prompting for confirmation.');

commandLine.parse();
'Delete the domain without prompting for confirmation.')
.parse();

commandLine.assertHaveDomainName();
commandLine.assertDomainExists();
Expand Down
5 changes: 2 additions & 3 deletions bin/cs-describe-domain
Expand Up @@ -11,9 +11,8 @@ commandLine
.option('-all, --show-all',
'Display all available information for the domain, '
+ 'including configured fields.',
String);

commandLine.parse();
String)
.parse();

function report(domain) {
console.log('Domain Name %s', domain.name);
Expand Down
5 changes: 2 additions & 3 deletions bin/gcs
Expand Up @@ -14,9 +14,8 @@ commandLine
'list of IP ranges for privileged client '+
'[' + CLI.defaultPrivilegedRanges + ']',
String,
CLI.defaultPrivilegedRanges);

commandLine.parse();
CLI.defaultPrivilegedRanges)
.parse();

var server = gcsServer.createServer({
databasePath: commandLine.options.databasePath,
Expand Down
11 changes: 8 additions & 3 deletions lib/command-line.js
Expand Up @@ -17,7 +17,7 @@ function CommandLineInterface() {
.option('--database-path <path>',
'database path [' + defaultDatabasePath + ']',
String,
defaultDatabasePath)
defaultDatabasePath);
}
CommandLineInterface.prototype = {
get databasePath() {
Expand All @@ -37,26 +37,31 @@ CommandLineInterface.prototype = {

parse: function() {
this.program.parse(process.argv);
return this;
},
usage: function() {
return this.program.option.apply(this.program, arguments);
this.program.option.apply(this.program, arguments);
return this;
},
option: function() {
return this.program.option.apply(this.program, arguments);
this.program.option.apply(this.program, arguments);
return this;
},

assertHaveDomainName: function() {
if (!this.options.domainName) {
console.log('You must specify the domain name.');
process.exit(1);
}
return this;
},

assertDomainExists: function() {
if (!this.domain.exists()) {
console.log('You must specify an existing domain name.');
process.exit(1);
}
return this;
},
};
exports.CommandLineInterface = CommandLineInterface;
Expand Down

0 comments on commit c4c93e5

Please sign in to comment.