How to use cli-table - 10 common examples

To help you get started, we’ve selected a few cli-table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexklibisz / firebak / src / backup.js View on Github external
{'max request size (mb)': result.maxRequestSize / 1000000},
      {'total request size (mb)': result.totalRequestSize / 1000000},
      {'total objects (not counting nested)': result.totalObjects}
    );

    console.info(` >> Backup complete: ${backup.path}`);
    console.info(tableComplete.toString() + '\n\n');

    // Update aggregate sizes
    maxRequestSize = Math.max(maxRequestSize, result.maxRequestSize);
    totalRequestSize += result.totalRequestSize;
    totalObjects += result.totalObjects;
    totalDuration += (t2 - t1) / 1000;
  }

  const table = new Table();
  table.push(
    {'total duration (sec)': totalDuration },
    {'max request size (mb)': maxRequestSize / 1000000 },
    {'total request size (mb)': totalRequestSize / 1000000 },
    { 'total objects (not counting nested)': totalObjects }
  );
  console.info(' >> Backup complete: all collections');
  console.info(table.toString());
}
github gladiusjs / gladius-core / node_modules / qunit / node_modules / cli-table / lib-cov / cli-table / index.js View on Github external
_$jscoverage['cli-table/index.js'][184]++;
  ret += chars.right;
}));
    _$jscoverage['cli-table/index.js'][187]++;
    ret += "\n";
  }
}));
  }
  _$jscoverage['cli-table/index.js'][191]++;
  line(chars.bottom, chars["bottom-left"] || chars.bottom, chars["bottom-right"] || chars.bottom, chars["bottom-mid"]);
  _$jscoverage['cli-table/index.js'][196]++;
  return ret;
});
_$jscoverage['cli-table/index.js'][203]++;
module.exports = Table;
_$jscoverage['cli-table/index.js'].source = ["","/**"," * Module dependencies."," */","","var utils = require('./utils')","  , repeat = utils.repeat","  , truncate = utils.truncate","  , pad = utils.pad;","","require('../../support/colors.js/colors');","","/**"," * Table constructor"," *"," * @param {Object} options"," * @api public"," */","","function Table (options){","  this.options = utils.options({","      chars: {","          'top': '━'","        , 'top-mid': '┳'","        , 'top-left': '┏'","        , 'top-right': '┓'","        , 'bottom': '━'","        , 'bottom-mid': '┻'","        , 'bottom-left': '┗' ","        , 'bottom-right': '┛'","        , 'left': '┃'","        , 'left-mid': '┣'","        , 'mid': '━'","        , 'mid-mid': '╋'","        , 'right': '┃'","        , 'right-mid': '┫'","      }","    , truncate: '…'","    , colWidths: []","    , colAligns: []","    , style: {","          'padding-left': 1","        , 'padding-right': 1","        , head: ['cyan']","      }","    , head: []","  }, options);","};","","/**"," * Inherit from Array."," */","","Table.prototype.__proto__ = Array.prototype;","","/**"," * Width getter"," *"," * @return {Number} width"," * @api public"," */","","Table.prototype.__defineGetter__('width', function (){","  var str = this.toString().split(\"\\n\");","  if (str.length) return str[0].length;","  return 0;","});","","/**"," * Render to a string."," *"," * @return {String} table representation"," * @api public"," */","","Table.prototype.render ","Table.prototype.toString = function (){","  var ret = ''","    , options = this.options","    , style = options.style","    , head = options.head","    , chars = options.chars","    , truncater = options.truncate","    , colWidths = options.colWidths || []","    , totalWidth = 0;","  ","  if (!head.length && !this.length) return '';","","  if (!colWidths.length){","    this.concat([head]).forEach(function(cells){","      cells.forEach(function(cell, i){","        var width = typeof cell == 'object' && cell.width != undefined","          ? cell.width ","          : ((typeof cell == 'object' ? String(cell.text) : String(cell)).length + (style['padding-left'] || 0) + (style['padding-right'] || 0))","        colWidths[i] = Math.max(colWidths[i] || 0, width || 0);","      });","    });","  };","","  totalWidth = (colWidths.length == 1 ? colWidths[0] : colWidths.reduce(","    function (a, b){","      return a + b","    })) + colWidths.length + 1;","","  // draws a line","  function line (line, left, right, intersection){","    var width = 0","      , line =","          left","        + repeat(line, totalWidth - 2)","        + right;","","    colWidths.forEach(function (w, i){","      if (i == colWidths.length - 1) return;","      width += w + 1;","      line = line.substr(0, width) + intersection + line.substr(width + 1);","    });","","    ret += line;","  };","","  // draws the top line","  function lineTop (){","    line(chars.top","       , chars['top-left'] || chars.top","       , chars['top-right'] ||  chars.top","       , chars['top-mid']);","    ret += \"\\n\";","  };","","  // renders a string, by padding it or truncating it","  function string (str, index){","    var str = String(typeof str == 'object' && str.text ? str.text : str)","      , length = str.length","      , width = colWidths[index]","          - (style['padding-left'] || 0)","          - (style['padding-right'] || 0)","      , align = options.colAligns[index] || 'left';","","    return repeat(' ', style['padding-left'] || 0)","         + (length == width ? str :","             (length < width ","              ? pad(str, width, ' ', align == 'left' ? 'right' : ","                  (align == 'middle' ? 'both' : 'left'))","              : (truncater ? truncate(str, width, truncater) : str))","           )","         + repeat(' ', style['padding-right'] || 0);","  };","","  if (head.length){","    lineTop();","","    ret += chars.left;","    ","    head.forEach(function (th, index){","      var text = string(th, index);","      if (style.head){","        style.head.forEach(function(style){","          text = text[style];","        });","      }","","      ret += text;","      ret += chars.right;","    });","","    ret += \"\\n\";","  }","","  if (this.length)","    this.forEach(function (cells, i){","      if (!head.length && i == 0)","        lineTop();","      else {","        line(chars.mid","           , chars['left-mid']","           , chars['right-mid']","           , chars['mid-mid']);","","        ret += \"\\n\" + chars.left;","","        cells.forEach(function(cell, i){","          ret += string(cell, i);","          ret += chars.right;","        });","","        ret += \"\\n\";","      }","    });","","  line(chars.bottom","     , chars['bottom-left'] || chars.bottom","     , chars['bottom-right'] || chars.bottom","     , chars['bottom-mid']);","","  return ret;","};","","/**"," * Module exports."," */","","module.exports = Table;"];
github gladiusjs / gladius-core / node_modules / qunit / node_modules / cli-table / lib-cov / cli-table / index.js View on Github external
/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['cli-table/index.js']) {
  _$jscoverage['cli-table/index.js'] = [];
  _$jscoverage['cli-table/index.js'][6] = 0;
  _$jscoverage['cli-table/index.js'][11] = 0;
  _$jscoverage['cli-table/index.js'][20] = 0;
  _$jscoverage['cli-table/index.js'][21] = 0;
  _$jscoverage['cli-table/index.js'][48] = 0;
  _$jscoverage['cli-table/index.js'][54] = 0;
  _$jscoverage['cli-table/index.js'][63] = 0;
  _$jscoverage['cli-table/index.js'][64] = 0;
  _$jscoverage['cli-table/index.js'][65] = 0;
  _$jscoverage['cli-table/index.js'][66] = 0;
  _$jscoverage['cli-table/index.js'][76] = 0;
  _$jscoverage['cli-table/index.js'][77] = 0;
  _$jscoverage['cli-table/index.js'][78] = 0;
  _$jscoverage['cli-table/index.js'][87] = 0;
  _$jscoverage['cli-table/index.js'][89] = 0;
github oors / oors / packages / oors-logger / src / index.js View on Github external
printModules() {
    const modulesTable = new Table({
      head: ['Modules'],
    });

    this.manager.on('module:loaded', module => {
      modulesTable.push([module.name]);
    });

    this.manager.once('after:setup', () => {
      console.log(modulesTable.toString());
    });
  }
github dawson-org / dawson-cli / src / commands / describe.js View on Github external
title('Stack Resources');
        console.log(table.toString());
      }

      if (!shell) {
        log('');
      }

      const outputValues = Object.values(outputs);
      const sortedOutputs = sortBy(outputValues, ['OutputKey']);
      if (shell) {
        sortedOutputs.forEach(({ OutputKey, OutputValue }) => {
          process.stdout.write(`${OutputKey}=${OutputValue}\n`);
        });
      } else {
        const table = new Table({ head: ['OutputKey', 'OutputValue'] });
        table.push(
          ...sortedOutputs.map(({ OutputKey, OutputValue }) => [
            OutputKey,
            OutputValue
          ])
        );
        title('Stack Outputs');
        log(
          'Please do not copy-paste any OutputValue into your functions. These values are available from the params.stageVariables. in every lambda function.'.yellow.dim
        );
        console.log(table.toString());
      }
    })
    .catch(err => error('Command error', err));
github dawson-org / dawson-cli / src / libs / cloudformation.js View on Github external
.then(describeResult => {
          const failedEvents = describeResult.StackEvents
            .filter(e => e.Timestamp >= startTimestamp)
            .filter(e => e.ResourceStatus.includes('FAILED'))
            .map(e => [
              moment(e.Timestamp).fromNow(),
              e.ResourceStatus || '',
              e.ResourceStatusReason || '',
              e.LogicalResourceId || ''
            ]);
          const table = new Table({
            head: ['Timestamp', 'Status', 'Reason', 'Logical Id']
          });
          table.push(...failedEvents);
          if (describeResult.StackEvents[0]) {
            error();
          }
          done(createError({
            kind: 'Stack update failed',
            reason: 'The stack update has failed because of an error',
            detailedReason: (
                table.toString() +
                  '\n' +
                  chalk.gray(
                    oneLineTrim`
                You may further inspect stack events from the console at this link:
                https://${AWS_REGION}.console.aws.amazon.com/cloudformation/home
github aragon / aragon-cli / packages / cli / src / commands / apm_cmds / packages.js View on Github external
function displayPackages(packages) {
  const table = new Table({
    head: ['App', 'Latest Version'],
  })

  packages.forEach(aPackage => {
    const row = [aPackage.name, aPackage.version]
    table.push(row)
  })

  console.log('\n', table.toString())
}
github aragon / aragon-cli / packages / cli / src / commands / dao_cmds / apps.js View on Github external
const printPermissionlessApps = apps => {
  if (apps && apps.length) {
    const tableForPermissionlessApps = new Table({
      head: ['Permissionless app', 'Proxy address'].map(x => white(x)),
    })
    apps.forEach(app =>
      tableForPermissionlessApps.push([
        printAppNameFromAppId(app.appId).replace('.aragonpm.eth', ''),
        app.proxyAddress,
      ])
    )
    console.log(tableForPermissionlessApps.toString())
  }
}
github electrode-io / electrode-native / ern-core / src / compatibility.js View on Github external
export async function logCompatibilityReportTable (report: Object) {
  var table = new Table({
    head: [
      chalk.cyan('Name'),
      chalk.cyan('Needed Version'),
      chalk.cyan('Local Version')
    ],
    colWidths: [40, 16, 15]
  })

  for (const compatibleEntry of report.compatible) {
    table.push([
      compatibleEntry.dependencyName,
      chalk.green(compatibleEntry.remoteVersion ? compatibleEntry.remoteVersion : ''),
      chalk.green(compatibleEntry.localVersion ? compatibleEntry.localVersion : '')
    ])
  }
github LiferayCloud / magnet / src / routes.js View on Github external
export function getRoutesTable(magnet) {
  const table = new Table({
    head: ['method', 'path', 'type', 'file'],
    style: {
      border: ['gray'],
      compact: true,
      head: ['gray'],
    },
  });
  table.push(...getRoutesDefinition_(magnet));
  if (table.length) {
    return table.toString();
  }
  return '';
}

cli-table

Pretty unicode tables for the CLI

MIT
Latest version published 3 years ago

Package Health Score

76 / 100
Full package analysis