azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
158 lines (68 loc) • 5.71 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var $ = utils.getLocaleString;
function capitalize(str) {
if ((str && (str.length >= 1))) {
return (str.charAt(0).toUpperCase() + str.slice(1)); }
else {
return str; } ;};
function makeTuple(k, v, d) {
return { key: k, value: v, depth: d };};
function displayImpl(o, key, depth, arr) {
if (((!!o) && (((o.constructor === Object) || (o.constructor === Array))))) {
arr.push(makeTuple(key, "", depth));
var len = 0;
Object.keys(o).forEach(function(k1) {
var v1 = o[k1];
var p1 = ((o.constructor === Array) ? "#" : "");
var w = displayImpl(v1, (p1 + k1), (depth + 1), arr);
if ((w > len)) {
len = w; } ; });
return len; }
else {
arr.push(makeTuple(key, (o ? o.toString() : ""), depth));
return ((depth * 2) + ((key ? key.toString().length : 0))); } ;};
function display(cli, o) {
var arr = [];
var width = displayImpl(o, "", 0, arr);
for (var t in arr) {
var prebuf = new Array((arr[t].depth * 2)).join(" ");
var key = (arr[t].key ? arr[t].key : "");
var postLen = (width - ((prebuf.length + key.length)));
var postbuf = new Array(((postLen > 0) ? postLen : 0)).join(" ");
var str = ((prebuf + capitalize(key)) + postbuf);
if (arr[t].value) {
str += (" : " + arr[t].value); } ;
cli.output.data(str); };};
exports.init = function(cli) {
var virtualMachineRunCommandsGet = cli.category("run-command").description($("Commands to manage your virtual machine run commands. "));
virtualMachineRunCommandsGet.command("show [location] [command-id]").description($("Gets specific run command for a subscription in a location.")).usage("[options] <location> <command-id>").option("--location <location>", $("location")).option("--command-id <command-id>", $("command-id")).option("-s, --subscription <subscription>", $("The subscription identifier")).execute(function __1(location, commandId, options, _) { var subscription, computeManagementClient, result; var __frame = { name: "__1", line: 106 }; return __func(_, this, arguments, __1, 3, __frame, function __$__1() { return (function __$__1(__then) {
if (!location) {
return cli.interaction.promptIfNotGiven($("location : "), location, __cb(_, __frame, 2, 33, function ___(__0, __1) { location = __1; __then(); }, true)); } else { __then(); } ; })(function __$__1() {
cli.output.verbose(("location = " + location)); return (function __$__1(__then) {
if (!commandId) {
return cli.interaction.promptIfNotGiven($("command-id : "), commandId, __cb(_, __frame, 7, 34, function ___(__0, __2) { commandId = __2; __then(); }, true)); } else { __then(); } ; })(function __$__1() {
cli.output.verbose(("commandId = " + commandId));
subscription = profile.current.getSubscription(options.subscription);
computeManagementClient = utils.createComputeManagementClient(subscription);
return computeManagementClient.virtualMachineRunCommands.get(location, commandId, __cb(_, __frame, 13, 67, function ___(__0, __3) { result = __3;
if (cli.output.format().json) {
cli.output.json(result); }
else {
display(cli, result); } ; _(); }, true)); }); }); }); });
var virtualMachineRunCommandsList = cli.category("run-command").description($("Commands to manage your virtual machine run commands. "));
virtualMachineRunCommandsList.command("list [location]").description($("Lists all available run commands for a subscription in a location.")).usage("[options] <location>").option("--location <location>", $("location")).option("-s, --subscription <subscription>", $("The subscription identifier")).execute(function __2(location, options, _) { var subscription, computeManagementClient, result, nextPageLink, pageResult; var __frame = { name: "__2", line: 138 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { return (function __$__2(__then) {
if (!location) {
return cli.interaction.promptIfNotGiven($("location : "), location, __cb(_, __frame, 2, 33, function ___(__0, __1) { location = __1; __then(); }, true)); } else { __then(); } ; })(function __$__2() {
cli.output.verbose(("location = " + location));
subscription = profile.current.getSubscription(options.subscription);
computeManagementClient = utils.createComputeManagementClient(subscription);
return computeManagementClient.virtualMachineRunCommands.list(location, __cb(_, __frame, 8, 67, function ___(__0, __2) { result = __2;
nextPageLink = result.nextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$__2() { __more = false;
var __6 = nextPageLink; if (__6) {
return computeManagementClient.virtualMachineRunCommands.listNext(nextPageLink, __cb(_, __frame, 11, 73, function ___(__0, __3) { pageResult = __3;
pageResult.forEach(function(item) {
result.push(item); });
nextPageLink = pageResult.nextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$__2() {
if (result) {
cli.output.json(result); } ; _(); }); }, true)); }); }); });};