azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
143 lines (66 loc) • 6.94 kB
JavaScript
/*** 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 siteDomain = site.category("handler").description($("Commands to manage your Web Site handler mappings"));
siteDomain.command("list [name]").usage("[options] [name]").description($("Show your site handler mappings 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.handlerMappings, function(data) {
if ((data.length > 0)) {
log.table(data, function(row, item) {
row.cell($("Extension"), item.extension);
row.cell($("Script Processor Path"), item.scriptProcessor);
row.cell($("Additional Arguments"), (item.arguments ? item.arguments : "")); }); }
else {
log.info($("No handler mappings defined yet")); } ; }); _(); }, true)); }, true)); }); });
siteDomain.command("add [extension] [processor] [name]").usage("[options] <extension> <processor> [name]").description($("Add a handler mapping")).option("-e, --extension <extension>", $("the handler mapping extension")).option("-p, --processor <processor>", $("the path to the script processor (executable that will process the file given by the extension)")).option("-a, --arguments <arguments>", $("the additional arguments")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __2(extension, processor, name, options, _) { var parsedSiteName, context, siteConfigurations, handler, __arguments = arguments; var __frame = { name: "__2", line: 70 }; return __func(_, this, arguments, __2, 4, __frame, function __$__2() {
parsedSiteName = WebsitesClient.parseSiteName(name);
context = {
subscription: profile.current.getSubscription(options.subscription).id,
site: {
name: parsedSiteName.name,
slot: (options.slot ? options.slot : parsedSiteName.slot) } };
return cli.interaction.promptIfNotGiven($("Extension: "), extension, __cb(_, __frame, 10, 34, function ___(__0, __1) { extension = __1;
return cli.interaction.promptIfNotGiven($("Script Processor Path: "), processor, __cb(_, __frame, 11, 34, function ___(__0, __2) { processor = __2;
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 13, 11, function __$__2() {
return site.doSiteConfigGet(context, __cb(_, __frame, 15, 36, function ___(__0, __3) { siteConfigurations = __3;
handler = { };
if (options["arguments"]) {
handler.__arguments = options["arguments"]; } ;
handler["extension"] = extension;
handler["scriptProcessor"] = processor;
siteConfigurations.handlerMappings.push(handler);
return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 27, 11, function __$__2() { _(); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
siteDomain.command("delete [extension] [name]").usage("[options] <extension> [name]").description($("Delete a site handler mapping")).option("-e, --extension <extension>", $("the extension")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __3(extension, name, options, _) { var parsedSiteName, context, siteConfigurations, found, i; var __frame = { name: "__3", line: 107 }; return __func(_, this, arguments, __3, 3, __frame, 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 cli.interaction.promptIfNotGiven($("Extension: "), extension, __cb(_, __frame, 10, 34, function ___(__0, __2) { extension = __2; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete handler mapping with %s extension? [y/n] "), extension), __cb(_, __frame, 12, 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() {
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 16, 11, function __$__3() {
return site.doSiteConfigGet(context, __cb(_, __frame, 18, 36, function ___(__0, __4) { siteConfigurations = __4;
found = false; return (function __$__3(__then) {
if (siteConfigurations.handlerMappings) {
for (i = 0; (i < siteConfigurations.handlerMappings.length); i++) {
if (utils.ignoreCaseEquals(siteConfigurations.handlerMappings[i].extension, extension)) {
siteConfigurations.handlerMappings.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($("Handler mapping for extension \"%s\" does not exist"), extension))); } ; _(); }); }, true)); }, true)); }); }, true)); }, true)); }); });};