How to use cli-table3 - 10 common examples

To help you get started, we’ve selected a few cli-table3 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 IBM / report-toolkit / packages / transformers / src / table.js View on Github external
const createTable = (opts = {}) => {
  opts = _.defaultsDeep(DEFAULT_TABLE_OPTS, opts);
  const {fields, maxWidth, truncate, colWidths} = opts;
  if (truncate) {
    opts.colWidths = calculateColumnWidths(fields, colWidths, maxWidth);
  }
  return new CLITable3({
    // "truncate" is used by CLITable3 for the truncation symbol.
    ..._.omit('truncate', opts),
    head: formatTableHeaders(fields),
    truncate: '…'
  });
};
github trolster / urcli / src / commands / assign / prompt.js View on Github external
// node modules
import readline from 'readline';
// npm modules
import moment from 'moment';
import Table from 'cli-table3';
import chalk from 'chalk';
// our modules
import env from './assignConfig';
import {api, config} from '../../utils';

// Create a new table for projects that the user is queued up for
const projectDetailsTable = new Table({
  head: [
    {hAlign: 'center', content: 'pos'},
    {hAlign: 'center', content: 'id'},
    {hAlign: 'left', content: 'project name'},
    {hAlign: 'center', content: 'lang'}],
  colWidths: [5, 7, 40, 7],
});

// Shows assigned projects in a table
const assignedDetailsTable = new Table({
  head: [
    {hAlign: 'center', content: 'key'},
    {hAlign: 'left', content: 'project name'},
    {hAlign: 'center', content: 'expires'},
    {hAlign: 'center', content: 'price'}],
  colWidths: [5, 40, 15, 8],
github trolster / urcli / src / commands / certs.js View on Github external
async function certsCmd() {
  const certSpinner = ora('Getting certifications...').start();
  await getCerts();

  // Create a table layout for presenting the certifications.
  const certsDetails = new Table({
    head: [
      {hAlign: 'center', content: 'id'},
      {hAlign: 'left', content: 'project name'},
      {hAlign: 'center', content: 'price'}],
    colWidths: [5, 40, 7],
  });
  Object.keys(config.certs)
    .sort((a, b) => a - b)
    .forEach((id) => {
      const {name, price} = config.certs[id];
      certsDetails.push([
        {hAlign: 'center', content: id},
        {hAlign: 'left', content: name},
        {hAlign: 'center', content: price},
      ]);
    });
github uber / xviz / modules / cli / src / cmds / validate.js View on Github external
function printErrorSummary(stats, args) {
  // Form a table of the main errors one row per type
  const table = new Table({
    head: ['Type', 'Count', 'Invalid', 'Inv %', 'Unique Errors'],
    style: {head: ['white', 'bold']}
  });

  for (const message in stats.messages) {
    const count = stats.messages[message] || 0;
    const errors = stats.validationErrors[message] || 0;
    const errPer = (errors / count) * 100;

    const uniqueErrors = stats.uniqueErrors[message];
    const uniqueErrorCount = uniqueErrors ? Object.keys(uniqueErrors).length : 0;

    const row = [message, count, errors, errPer.toFixed(1), uniqueErrorCount];

    if (errors) {
      const coloredRow = [];
github yarnpkg / yarn / src / reporters / console / console-reporter.js View on Github external
return [
        {[chalk.bold(colorSeverity(auditAdvisory.severity))]: chalk.bold(auditAdvisory.title)},
        {Package: auditAdvisory.module_name},
        ...patchRows,
        {'Dependency of': `${resolution.path.split('>')[0]} ${resolution.dev ? '[dev]' : ''}`},
        {Path: resolution.path.split('>').join(' > ')},
        {'More info': `https://www.npmjs.com/advisories/${auditAdvisory.id}`},
      ];
    }

    const tableOptions = {
      colWidths: AUDIT_COL_WIDTHS,
      wordWrap: true,
    };
    const table = new Table(tableOptions);
    const patchedIn =
      auditAdvisory.patched_versions.replace(' ', '') === '<0.0.0'
        ? 'No patch available'
        : auditAdvisory.patched_versions;
    table.push(...makeAdvisoryTableRow(patchedIn));
    this._log(table.toString());
  }
}
github emyann / matron / packages / matron / src / templates / templates.list.ts View on Github external
async function templatesCommand(options: TemplatesCommand) {
  switch (options.cmd) {
    case TemplatesSubCommand.list: {
      const templates = await githubClient().listTemplates();
      const table = new Table({
        head: [displayH1`Name`, displayH1`Provider`],
        colWidths: [50, 25]
      }) as HorizontalTable;

      const entries = templates.map(template => [template, 'matron']);
      table.push(...entries);

      console.log(table.toString());
    }
    default:
      break;
  }
}
github foxythemes / jira-cli / src / versions.js View on Github external
showVersions ( versions ) {

    if ( versions.length ) {
      const table = new Table({
        chars: jira.tableChars,
        head: ['Name', 'Status', 'Release Date']
      });

      versions.forEach(function( version ){
        const name = version.name;
        const released = version.released ? color.green( 'Released' ) : color.red( 'Unreleased' );
        const releaseDate = version.releaseDate ? version.releaseDate : '';

        table.push(
        [ name, released, releaseDate ]
        );
      });

      console.log( table.toString() );
    } else {
github Yoctol / bottender / packages / bottender / src / cli / providers / messenger / webhook.ts View on Github external
);
      print(
        'See more on: https://developers.facebook.com/docs/graph-api/reference/app/subscriptions'
      );
    }

    const fields = config.fields || defaultFields;

    const tokenInfo = await client.debugToken();

    invariant(tokenInfo.isValid, 'Page access token is invalid');
    invariant(tokenInfo.type === 'PAGE', 'Access token is not a page token');

    const pageInfo = await client.getPageInfo();

    const table = new Table();

    table.push(
      [chalk.green('Page ID'), pageInfo.id] as any,
      [chalk.green('Page Name'), pageInfo.name] as any,
      [chalk.green('App Name'), tokenInfo.application] as any,
      [
        chalk.green('Token Expires At'),
        tokenInfo.expiresAt === 0
          ? 'Never'
          : new Date(tokenInfo.expiresAt * 1000).toString(),
      ] as any,
      [chalk.green('Token Scopes'), tokenInfo.scopes.join(',')] as any,
      [chalk.green('App Fields'), fields.join(',')] as any,
      [chalk.green('Webhook URL'), webhook] as any
    );
github jaebradley / http-status-identifier-cli / src / StatusTableCreator.js View on Github external
createInitialTable(showFullInformation) {
    const properties = { wordWrap: this.wordWrap };
    if (showFullInformation) {
      properties.colWidths = [
        this.columnWidth,
        this.longColumnWidth,
      ];
    } else {
      properties.colWidths = [
        this.columnWidth,
        this.columnWidth,
      ];
    }

    return new Table(properties);
  }
github storybookjs / storybook / lib / core / src / server / build-dev.js View on Github external
function outputStartupInformation(options) {
  const {
    updateInfo,
    version,
    address,
    networkAddress,
    managerTotalTime,
    previewTotalTime,
  } = options;

  const updateMessage = createUpdateMessage(updateInfo, version);

  const serveMessage = new Table({
    chars: {
      top: '',
      'top-mid': '',
      'top-left': '',
      'top-right': '',
      bottom: '',
      'bottom-mid': '',
      'bottom-left': '',
      'bottom-right': '',
      left: '',
      'left-mid': '',
      mid: '',
      'mid-mid': '',
      right: '',
      'right-mid': '',
      middle: '',

cli-table3

Pretty unicode tables for the command line. Based on the original cli-table.

MIT
Latest version published 6 months ago

Package Health Score

79 / 100
Full package analysis