'use strict';

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

var _chalk = require('chalk');

var _chalk2 = _interopRequireDefault(_chalk);

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

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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 SocketConfigShowCmd {
  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);
      }

      (0, _printTools.echo)();
      Object.keys(_this.socket.remote.spec.config).forEach(function (optionName) {
        const params = _this.socket.remote.spec.config[optionName];
        const required = params.required ? _chalk2.default.dim('(required)') : '';
        const currentValue = _this.socket.remote.config[optionName];

        (0, _printTools.echo)(_chalk2.default.dim('         name:'), `${_chalk2.default.bold(optionName)} ${required}`);
        (0, _printTools.echo)(_chalk2.default.dim('  description:'), params.description);
        (0, _printTools.echo)(_chalk2.default.dim('        value:'), currentValue);
        (0, _printTools.echo)();
      });
    })();
  }
}
exports.default = SocketConfigShowCmd;
module.exports = exports['default'];
//# sourceMappingURL=socket-config-show.js.map