@ethersphere/swarm-cli
Version:
CLI tool for Bee
77 lines (76 loc) • 3.44 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Show = void 0;
const history_command_1 = require("./history-command");
const furious_commander_1 = require("furious-commander");
const text_1 = require("../../utils/text");
const process_1 = require("process");
const history_1 = require("../../service/history");
class Show extends history_command_1.HistoryCommand {
constructor() {
super(...arguments);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: 'show'
});
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: 'Get upload history item'
});
Object.defineProperty(this, "index", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
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 history = new history_1.History(this.commandConfig, this.console);
const historyItem = history.getItemByIndex(this.index);
if (historyItem === undefined) {
this.console.error(`Cound not find history item with index '${this.index}'`);
(0, process_1.exit)(1);
}
this.console.log((0, text_1.createKeyValue)('Timestamp', new Date(historyItem.timestamp).toUTCString()));
this.console.log((0, text_1.createKeyValue)('Swarm hash', historyItem.reference));
this.console.log((0, text_1.createKeyValue)('Stamp ID', historyItem.stamp));
this.console.log((0, text_1.createKeyValue)('Upload type', historyItem.uploadType));
if (historyItem.path) {
this.console.log((0, text_1.createKeyValue)('Path', historyItem.path));
}
if (historyItem.feedAddress) {
this.console.log((0, text_1.createKeyValue)('Feed address', historyItem.feedAddress));
}
if (historyItem.feedIdentity) {
this.console.log((0, text_1.createKeyValue)('Feed identity', historyItem.feedIdentity));
}
}
}
exports.Show = Show;
__decorate([
(0, furious_commander_1.Argument)({
key: 'index',
description: 'Index of the history item',
required: true,
type: 'number',
}),
__metadata("design:type", Number)
], Show.prototype, "index", void 0);