Navigation Menu

Skip to content

Commit

Permalink
Add new command line tool cs-configure-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 3, 2012
1 parent ae60330 commit 82d5604
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
54 changes: 54 additions & 0 deletions bin/cs-configure-fields
@@ -0,0 +1,54 @@
#!/usr/bin/env node

var program = require('commander');
var commandLine = require(__dirname + '/../lib/command-line');

program
.version(require('../package').version)
.usage('--name <field name> --type <field type> [options]')
.option('--name <field name>',
'The name of the field you are configuring or deleting. Required.',
String)
.option('--type <field type>',
'The type of the field that you are configuring or deleting: ' +
'text, literal, uint. Required.',
String)
.option('-d, --type <field type>',
'The name of the domain that you are configuring. Required.',
String)
.option('--delete',
'Delete the field specified by the --name and --type options.')
.option('--database-path <path>',
'database path [' + commandLine.defaultDatabasePath + ']',
String,
commandLine.defaultDatabasePath)
.parse(process.argv);

if (!program.domainName) {
console.log('You must specify the domain name.');
return false;
}

var context = commandLine.getContext(program.databasePath);
var domain = new commandLine.Domain(program.domainName, context);
if (!domain.exists()) {
console.log('You must specify an existing domain name.');
return false;
}

if (!program.name) {
console.log('You must specify the field name.');
return false;
}
if (!program.type) {
console.log('You must specify the field type.');
return false;
}

var field = domain.getIndexField(program.name);
field.type = program.type;

field.createSync();

console.log('Updated 1 Index Field:');
console.log(field.name + ' ' + field.state + ' ' + field.type + '()');
4 changes: 2 additions & 2 deletions bin/cs-create-domain
Expand Up @@ -5,9 +5,9 @@ var commandLine = require(__dirname + '/../lib/command-line');

program
.version(require('../package').version)
.usage('[options] --domain-name <domain name>')
.usage('--domain-name <domain name> [options]')
.option('-d, --domain-name <domain name>',
'name for the new domain',
'The name of the domain that you are creating. Required.',
String)
.option('--database-path <path>',
'database path [' + commandLine.defaultDatabasePath + ']',
Expand Down
5 changes: 3 additions & 2 deletions bin/cs-describe-domain
Expand Up @@ -7,10 +7,11 @@ program
.version(require('../package').version)
.usage('[options]')
.option('-d, --domain-name <domain name>',
'name for the new domain',
'The name of the domain that you are creating. Required.',
String)
.option('-all, --show-all',
'name for the new domain',
'Display all available information for the domain, '
'including configured fields.',
String)
.option('--database-path <path>',
'database path [' + commandLine.defaultDatabasePath + ']',
Expand Down

0 comments on commit 82d5604

Please sign in to comment.