null+****@clear*****
null+****@clear*****
2012年 8月 6日 (月) 15:47:28 JST
SHIMODA Hiroshi 2012-08-06 15:47:28 +0900 (Mon, 06 Aug 2012) New Revision: fe15e97764b16d29f500c94c2745ebdcb95d187e https://github.com/groonga/gcs/commit/fe15e97764b16d29f500c94c2745ebdcb95d187e Log: Add a command to delete domain Added files: bin/cs-delete-domain Modified files: test/cs-commands.test.js Added: bin/cs-delete-domain (+45 -0) 100755 =================================================================== --- /dev/null +++ bin/cs-delete-domain 2012-08-06 15:47:28 +0900 (1f0d418) @@ -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); + } + }); +} Modified: test/cs-commands.test.js (+29 -0) =================================================================== --- test/cs-commands.test.js 2012-08-06 15:23:36 +0900 (8b9b1d6) +++ test/cs-commands.test.js 2012-08-06 15:47:28 +0900 (de7e7aa) @@ -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); -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B... 다운로드