"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CatScopeCmd = void 0;
function _cliTable() {
  const data = _interopRequireDefault(require("cli-table"));
  _cliTable = function () {
    return data;
  };
  return data;
}
function _catScope() {
  const data = require("./cat-scope");
  _catScope = function () {
    return data;
  };
  return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
class CatScopeCmd {
  constructor() {
    _defineProperty(this, "name", 'cat-scope [scopePath]');
    _defineProperty(this, "description", 'cat a scope and show all the contents');
    _defineProperty(this, "private", true);
    _defineProperty(this, "loader", false);
    _defineProperty(this, "alias", '');
    _defineProperty(this, "options", [['f', 'full', 'show all of the objects in the scope (except "Source")'], ['j', 'json', 'print the objects as a json format'], ['e', 'json-extra', 'add hash and object type to the json']]);
    _defineProperty(this, "loadAspects", false);
  }
  async report([scopePath], {
    full
  }) {
    const payload = await (0, _catScope().catScope)(scopePath || process.cwd(), full);
    if (!full) {
      const table = new (_cliTable().default)({
        head: ['id', 'Object', 'Type'],
        style: {
          head: ['cyan']
        }
      });
      payload.forEach(co => {
        table.push([co.id(), `obj: ${co.hash().toString()}`, co.getType()]);
      });
      return table.toString();
    }
    return payload.map(co => `> ${co.hash().toString()}\n\n${co.id()}\n`).join('\n');
  }
  async json([scopePath], {
    full,
    jsonExtra
  }) {
    const payload = await (0, _catScope().catScope)(scopePath || process.cwd(), full);
    if (jsonExtra) {
      payload.forEach(obj => {
        // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
        obj.hash = obj.hash().toString();
        // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
        obj.type = obj.constructor.name;
      });
    }
    return payload;
  }
}
exports.CatScopeCmd = CatScopeCmd;

//# sourceMappingURL=cat-scope-cmd.js.map