'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _socket = require('./helpers/socket');

var _printTools = require('../utils/print-tools');

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

class SocketConfigCmd {
  constructor(context) {
    this.session = context.session;
    this.Socket = context.Socket;
  }

  run([socketName, cmd]) {
    var _this = this;

    return _asyncToGenerator(function* () {
      _this.socket = yield _this.Socket.get(socketName);

      if (!_this.socket.existRemotely) {
        (0, _printTools.echo)();
        (0, _printTools.error)(4)('That socket was not synced!');
        (0, _printTools.echo)();
        process.exit(1);
      }

      if (_this.socket.remote.spec.config || {}) {
        (0, _printTools.echo)();
        (0, _printTools.warning)('That socket doesn\'t have any configuration options.');
        (0, _printTools.echo)();
        process.exit(1);
      }

      (0, _printTools.echo)();

      return (0, _socket.askForConfigOptionsToInstall)().then(function (config) {
        _this.socket.updateConfig(config);
        (0, _printTools.echo)();
      });
    })();
  }
}
exports.default = SocketConfigCmd;
module.exports = exports['default'];
//# sourceMappingURL=socket-config.js.map