Navigation Menu

Skip to content

Commit

Permalink
Add a command to delete domain
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 6, 2012
1 parent 484abb2 commit fe15e97
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
45 changes: 45 additions & 0 deletions bin/cs-delete-domain
@@ -0,0 +1,45 @@
#!/usr/bin/env node

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

program
.version(require('../package').version)
.usage('--domain-name <domain name> [options]')
.option('-d, --domain-name <domain name>',
'The name of the domain that you are deleting. Required.',
String)
.option('-f, --force',
'Delete the domain without prompting for confirmation.')
.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 process.exit(1);
}

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 process.exit(1);
}

if (program.force) {
domain.deleteSync();
console.log('Domain [' + domain.name + '] has been deleted successfully.');
} else {
program.confirm('Really delete? [' + domain.name + '] (y/N)', function(ok){
if (ok) {
domain.deleteSync();
console.log('Successfully deleted.');
process.exit(0);
} else {
process.exit(1);
}
});
}
29 changes: 29 additions & 0 deletions test/cs-commands.test.js
Expand Up @@ -89,6 +89,35 @@ suite('cs-create-domain', function() {
});
});

suite('cs-delete-domain', function() {
setup(commonSetup);
teardown(commonTeardown);

test('delete force', function(done) {
utils
.run('cs-create-domain',
'--domain-name', 'test',
'--database-path', temporaryDatabase.path)
.run('cs-delete-domain',
'--force',
'--database-path', temporaryDatabase.path)
.next(function(result) {
assert.equal(result.code, 0);
assert.include(result.output.stdout,
'Domain [test] has been deleted successfully.');

context.reopen();
var domain = new Domain('test', context);
assert.isFalse(domain.exists());

done();
})
.error(function(e) {
done(e);
});
});
});

suite('cs-describe-domain', function() {
setup(commonSetup);
teardown(commonTeardown);
Expand Down

0 comments on commit fe15e97

Please sign in to comment.