123456789101112131415161718192021222324252627282930313233343536373839404142 |
- "use strict";
- exports.__esModule = true;
- exports.exit = exports.passedTime = exports.formatTime = exports.printStatus = exports.parseArgs = void 0;
- var moment = require("moment");
- exports.parseArgs = function (args) {
- var inArgs = function (term) {
- return args.find(function (a) { return a.search(term) > -1; }) ? true : false;
- };
- var options = {
- verbose: inArgs("--verbose") ? 2 : inArgs("--quiet") ? 0 : 1,
- channel: inArgs("--channel"),
- council: inArgs("--council"),
- forum: inArgs("--forum"),
- proposals: inArgs("--proposals")
- };
- if (options.verbose > 1)
- console.debug("args", args, "\noptions", options);
- return options;
- };
- exports.printStatus = function (opts, data) {
- if (opts.verbose < 1)
- return;
- var block = data.block, chain = data.chain, proposals = data.proposals, cats = data.cats, posts = data.posts, threads = data.threads;
- var date = exports.formatTime();
- var message = "[" + date + "] Chain:" + chain + " Block:" + block + " ";
- if (opts.forum)
- message += "Post:" + posts[1] + " Cat:" + cats[1] + " Thread:" + threads[1] + " ";
- if (opts.proposals)
- message += "Proposals:" + proposals.current + " (Active:" + proposals.active.length + " Pending:" + proposals.executing.length + ") ";
- console.log(message);
- };
- // time
- exports.formatTime = function (time) {
- return moment(time).format("H:mm:ss");
- };
- exports.passedTime = function (start, now) {
- return exports.formatTime(moment.utc(moment(now).diff(moment(start))));
- };
- exports.exit = function (log) {
- log("\nNo connection, exiting.\n");
- process.exit();
- };
|