UNPKG

@ethersphere/swarm-cli

Version:
61 lines (60 loc) 2.11 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.List = void 0; const history_command_1 = require("./history-command"); const history_1 = require("../../service/history"); const cli_table3_1 = __importDefault(require("cli-table3")); const text_1 = require("../../utils/text"); class List extends history_command_1.HistoryCommand { constructor() { super(...arguments); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: 'list' }); Object.defineProperty(this, "alias", { enumerable: true, configurable: true, writable: true, value: 'ls' }); Object.defineProperty(this, "description", { enumerable: true, configurable: true, writable: true, value: 'Get upload history list' }); } run() { super.init(); if (!this.commandConfig.config.historyEnabled) { this.console.log((0, text_1.warningText)('Upload history tracking is not enabled. Use "swarm-cli history enable" command to enable it.')); return; } const table = new cli_table3_1.default({ head: ['Index', 'Timestamp', 'Reference', 'Postage stamp batch ID', 'File path', 'Upload type'], style: { head: ['green', 'bold'], }, wordWrap: true, }); const history = new history_1.History(this.commandConfig, this.console); table.push(...history .getItems() .map((h) => [ h.index, new Date(h.timestamp).toLocaleString(), h.reference.slice(0, 12), (0, text_1.ellipsis)(h.stamp, 6, -6), h.path, h.uploadType, ])); this.console.log(table.toString()); } } exports.List = List;