UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

143 lines (66 loc) 6.83 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; var util = require("util"); var profile = require("../../util/profile"); var utils = require("../../util/utils"); var WebsitesClient = require("./websites/websitesclient"); var $ = utils.getLocaleString; exports.init = function(cli) { var log = cli.output; var site = cli.category("site"); var siteDefaultDocument = site.category("defaultdocument").description($("Commands to manage your Web Site default documents")); siteDefaultDocument.command("list [name]").usage("[options] [name]").description($("Show your site default documents")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __1(name, options, _) { var parsedSiteName, context, siteConfigurations; var __frame = { name: "__1", line: 36 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 11, function __$__1() { return site.doSiteConfigGet(context, __cb(_, __frame, 12, 36, function ___(__0, __1) { siteConfigurations = __1; cli.interaction.formatOutput(siteConfigurations.defaultDocuments, function(data) { if ((data.length > 0)) { log.table(data, function(row, item) { row.cell("Name", item); }); } else { log.info($("No default documents defined yet")); } ; }); _(); }, true)); }, true)); }); }); siteDefaultDocument.command("add [document] [name]").usage("[options] <document> [name]").description($("Add a site default document (by default, to the end of the list)")).option("--slot <slot>", $("the name of the slot")).option("-d, --document <document>", $("the new default document")).option("-p, --position <position>", $("the position of the new default document")).option("-s, --subscription <id>", $("the subscription id")).execute(function __2(document, name, options, _) { var parsedSiteName, context, siteConfigurations; var __frame = { name: "__2", line: 67 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() { return cli.interaction.promptIfNotGiven($("Document: "), document, __cb(_, __frame, 1, 33, function ___(__0, __1) { document = __1; parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 12, 11, function __$__2() { return site.doSiteConfigGet(context, __cb(_, __frame, 14, 36, function ___(__0, __2) { siteConfigurations = __2; if ((siteConfigurations.defaultDocuments.indexOf(document) > -1)) { return _(new Error($("Duplicate default document"))); } ; if (options.position) { if ((options.position > siteConfigurations.defaultDocuments.length)) { return _(new Error(util.format($("Provided position %s is larger than current default document number %s"), options.position, siteConfigurations.defaultDocuments.length))); } else { siteConfigurations.defaultDocuments.splice(options.position, 0, document); } ; } else { siteConfigurations.defaultDocuments.push(document); } ; return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 30, 11, function __$__2() { _(); }, true)); }, true)); }, true)); }, true)); }); }); siteDefaultDocument.command("delete [document] [name]").usage("[options] <document> [name]").description($("Delete a site default document")).option("--slot <slot>", $("the name of the slot")).option("-d, --document <document>", $("the new default document")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <id>", $("the subscription id")).execute(function __3(document, name, options, _) { var parsedSiteName, context, siteConfigurations, found, i; var __frame = { name: "__3", line: 107 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { return cli.interaction.promptIfNotGiven("Document: ", document, __cb(_, __frame, 1, 33, function ___(__0, __2) { document = __2; return (function __$__3(_) { var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete default document %s? [y/n] "), document), __cb(_, __frame, 3, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -106, 18, function ___(__0, __3) { return (function __$__3(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$__3() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 16, 11, function __$__3() { return site.doSiteConfigGet(context, __cb(_, __frame, 17, 36, function ___(__0, __4) { siteConfigurations = __4; found = false; return (function __$__3(__then) { if (siteConfigurations.defaultDocuments) { for (i = 0; (i < siteConfigurations.defaultDocuments.length); i++) { if (utils.ignoreCaseEquals(siteConfigurations.defaultDocuments[i], document)) { siteConfigurations.defaultDocuments.splice(i, 1); found = true; i--; } ; }; return (function __$__3(__then) { if (found) { return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 30, 15, __then, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$__3() { if (!found) { return _(new Error(util.format("Default document \"%s\" does not exist.", document))); } ; _(); }); }, true)); }, true)); }); }, true)); }, true)); }); });};