/*** 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 util = require("util");


















var profile = require("../../../util/profile");
var utils = require("../../../util/utils");

var $ = utils.getLocaleString;

exports.init = function(cli) {
  var log = cli.output;
  var withProgress = cli.interaction.withProgress.bind(cli.interaction);

  var feature = cli.category("feature").description($("Commands to manage your features"));


  feature.command("list").description($("List all features available for your subscription")).usage("[options]").option("--subscription <subscription>", $("the subscription identifier")).execute(function __1(options, _) { var subscription, client, allFeatures; var __frame = { name: "__1", line: 36 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {




      subscription = profile.current.getSubscription(options.subscription);
      client = utils.createResourceFeatureClient(subscription);
      return client.features.listAll(__cb(_, __frame, 3, 40, function ___(__0, __1) { allFeatures = __1;
        cli.interaction.formatOutput(allFeatures, function(data) {
          if ((data.length === 0)) {
            log.info($("No features were found")); }
           else {
            log.table(data, function(row, feature) {
              row.cell($("Provider Name"), getProviderName(feature.name));
              row.cell($("Feature Name"), getFeatureName(feature.name));
              row.cell($("Registration State"), feature.properties.state); }); } ; }); _(); }, true)); }); });





  feature.command("show [providerName] [featureName]").description($("Shows a feature")).usage("[options] <providerName> <featureName>").option("-p --providerName <providerName>", $("the resource provider name")).option("-n --featureName <featureName>", $("the feature name")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __2(providerName, featureName, options, _) { var subscription, client, feature; var __frame = { name: "__2", line: 59 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {






      if (!providerName) {
        return _(null, cli.missingArgument("providerName")); } else {
        if (!featureName) {
          return _(null, cli.missingArgument("featureName")); } ; } ;

      subscription = profile.current.getSubscription(options.subscription);
      client = utils.createResourceFeatureClient(subscription);

      return client.features.get(providerName, featureName, __cb(_, __frame, 9, 36, function ___(__0, __1) { feature = __1;

        cli.interaction.formatOutput(feature, function(data) {
          if (!data) {
            log.info($("No such feature was found")); }
           else {
            log.data(($("Feature Name:       ") + getFeatureName(data.name)));
            log.data(($("Provider Name:      ") + getProviderName(data.name)));
            log.data(($("Registration State: ") + feature.properties.state)); } ; }); _(); }, true)); }); });




  feature.command("register [providerName] [featureName]").description($("Registers a previewed feature of a resource provider.")).usage("[options] <providerName> <featureName>").option("-p --providerName <providerName>", $("the resource provider name")).option("-n --name <featureName>", $("the feature name")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __3(providerName, featureName, options, _) { var subscription, client; var __frame = { name: "__3", line: 87 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {






      if (!providerName) {
        return _(null, cli.missingArgument("providerName")); } else {
        if (!featureName) {
          return _(null, cli.missingArgument("featureName")); } ; } ;

      subscription = profile.current.getSubscription(options.subscription);
      client = utils.createResourceFeatureClient(subscription);

      return withProgress(util.format($("Registering feature %s with subscription %s"), featureName, subscription.id), function __1(log, _) { var __frame = { name: "__1", line: 97 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {

          return client.features.register(providerName, featureName, __cb(_, __frame, 1, 26, function __$__1() { _(); }, true)); }); }, __cb(_, __frame, 9, 6, function __$__3() { _(); }, true)); }); });



  function getFeatureName(name) {
    return name.split("/")[1]; };


  function getProviderName(name) {
    return name.split("/")[0]; };};
