From f18b99de712991cfe3ec0220b4e7b60780faaf37 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Mon, 15 Oct 2012 16:35:09 +0900 Subject: [PATCH] Delete duplicated codes --- bin/gcs-delete-domain | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/bin/gcs-delete-domain b/bin/gcs-delete-domain index 09e11b8..99d58bf 100755 --- a/bin/gcs-delete-domain +++ b/bin/gcs-delete-domain @@ -14,7 +14,7 @@ commandLine commandLine.assertHaveDomainName(); commandLine.assertDomainExistsHTTP(function() { - if (commandLine.options.force) { + function doDelete(successMessage) { commandLine.cloudSearch.DeleteDomain( { DomainName: commandLine.domainName }, function(error, response) { @@ -22,26 +22,18 @@ commandLine.assertDomainExistsHTTP(function() { console.log('Unexpected error: ' + JSON.stringify(error)); process.exit(1); } else { - console.log('Domain [' + commandLine.domainName + '] has been deleted successfully.'); + console.log(successMessage); process.exit(0); } } }); + } + if (commandLine.options.force) { + doDelete('Domain [' + commandLine.domainName + '] has been deleted successfully.'); } else { commandLine.confirm('Really delete? [' + commandLine.domainName + '] (y/N) ', function(ok){ if (ok) { - commandLine.cloudSearch.DeleteDomain( - { DomainName: commandLine.domainName }, - function(error, response) { - if (error) { - console.log('Unexpected error: ' + JSON.stringify(error)); - process.exit(1); - } else { - console.log('Successfully deleted.'); - process.exit(0); - } - } - }); + doDelete('Successfully deleted.'); } else { process.exit(1); }