#!/usr/bin/env node // -*- mode: js -*- /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* * Copyright (c) 2018, Joyent, Inc. */ var cmdutil = require('cmdutil'); var moray = require('../lib'); var moraycli = require('../lib/cmd'); var clientOptions, parser, bucket, client; cmdutil.configure({ 'usageMessage': 'delete a bucket from Moray', 'synopses': [ moraycli.commonUsage + ' BUCKET' ] }); clientOptions = {}; parser = moraycli.parseCliOptions({ 'argv': process.argv, 'env': process.env, 'errstream': process.stderr, 'extraOptStr': '', 'clientOptions': clientOptions, 'onUsage': cmdutil.usage }); if (parser.optind() >= process.argv.length) { cmdutil.usage('missing required argument: "bucket"'); } bucket = process.argv[parser.optind()]; client = moray.createClient(clientOptions); client.on('error', cmdutil.fail); client.on('connect', function onConnect() { client.delBucket(bucket, function callback(err) { if (err) { cmdutil.fail(err); } moraycli.cliFinish(cmdutil, client); client.close(); }); });