How to use text-table - 10 common examples

To help you get started, we’ve selected a few text-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 zeit / now / packages / now-cli / src / commands / alias / ls.js View on Github external
function printAliasTable(aliases) {
  return `${table(
    [
      ['source', 'url', 'age'].map(h => chalk.gray(h)),
      ...aliases.map(a => [
        a.rules && a.rules.length
          ? chalk.cyan(`[${plural('rule', a.rules.length, true)}]`)
          : // for legacy reasons, we might have situations
          // where the deployment was deleted and the alias
          // not collected appropriately, and we need to handle it
          a.deployment && a.deployment.url
          ? a.deployment.url
          : chalk.gray('–'),
        a.alias,
        ms(Date.now() - new Date(a.created))
      ])
    ],
    {
github cheton / webappengine / gulp / tasks / i18next.js View on Github external
let tableData = [
        ['Key', 'Value']
    ];

    { // Using i18next-text
        parser.parseFuncFromString(content, { list: ['i18n._'] }, (key, options) => {
            const defaultValue = key;
            key = hash(defaultValue);
            options.defaultValue = defaultValue;
            parser.set(key, options);
            tableData.push([key, defaultValue]);
        });
    }

    if (_.size(tableData) > 1) {
        const text = table(tableData, { 'hsep': ' | ' });
        gutil.log('i18next-scanner:', file.relative + '\n' + text);
    } else {
        gutil.log('i18next-scanner:', file.relative);
    }

    done();
}
github pgilad / leasot / src / lib / reporters / table.ts View on Github external
let previousFile: string;

    const mapTodo = (item: TodoComment, index: number) => {
        let text = chalk.cyan(item.text);
        if (item.ref) {
            text = chalk.gray('@' + item.ref) + ' ' + text;
        }
        const line = ['', chalk.gray('line ' + item.line), chalk.green(item.tag), text];
        if (item.file !== previousFile) {
            headers[index] = item.file;
        }
        previousFile = item.file;
        return line;
    };

    let t = table(todos.map(mapTodo), {
        stringLength(str: string) {
            return stripAnsi(str).length;
        },
    });

    //set filename headers
    t = split(t)
        .map(function(el: string, i: number) {
            return headers[i] ? EOL + chalk.underline(headers[i]) + EOL + el : el;
        })
        .join(EOL);

    contents += t + EOL;
    return contents;
}
github wasmerio / webassembly.sh / src / services / wapm / wapm.js View on Github external
return [`${key}`, "WAPM"];
        })
      )
      .concat(
        Object.keys(this.uploadedCommands).map(key => {
          return [`${key}`, "uploaded by user"];
        })
      )
      .concat(
        Object.keys(this.callbackCommands).map(key => {
          return [`${key}`, "builtin"];
        })
      );

    let message = `LOCAL PACKAGES:
 ${table(packages, { align: ["l"], hsep: " | " }).replace(/\n/g, "\n ")}
    
LOCAL COMMANDS:
 ${table(commands, { align: ["l"], hsep: " | " }).replace(/\n/g, "\n ")}

Additional commands can be installed by: 
    • Running a command from any WASI package in https://wapm.io
    • Uploading a file with \`wapm upload\``;

    return message.replace(/\n\n/g, "\n \n");
  }
github ctx-core / ctx-core / quovo / cli.js View on Github external
async function cli$accounts(opts$ctx) {
  log(`${logPrefix}|cli$accounts`)
  await cli$ctx.quovo__access_token__agent()
  await cli$ctx.accounts__quovo__agent()
  cli.log(
    table(
      concat__array(
        [['id', 'username', 'user', 'brokerage_name', 'status']],
        cli$ctx.accounts__quovo.map(
          quovo__account =>
            quovo__account$row(quovo__account)))))
  return cli$ctx
}
function cli$cache$reset() {
github ctx-core / ctx-core / quovo / cli.js View on Github external
async function cli$users(opts$ctx) {
  log(`${logPrefix}|cli$users`)
  await cli$ctx.quovo__access_token__agent()
  await cli$ctx.users__quovo__agent()
  cli.log(
    table(
      concat__array(
        [['id', 'username', 'name', 'email']],
        cli$ctx.users__quovo.map(
          user__quovo => [
            user__quovo.id||'',
            user__quovo.username||'',
            user__quovo.name||'',
            user__quovo.email||''])
      )))
  return cli$ctx
}
function reset__cli$ctx() {
github cacjs / cac / src / index.js View on Github external
showHelp() {
    const optionsTable = table(Object.keys(this.options).map(option => [
      chalk.yellow(prefixedOption(option, this.aliasOptions)),
      chalk.dim(this.options[option].description),
      showDefaultValue(this.options[option].defaultValue)
    ]))

    const commandsTable = table(Object.keys(this.aliasCommands).map(command => {
      const alias = this.aliasCommands[command]
      return [
        chalk.yellow(`${command}${alias ? `, ${alias}` : ''}`),
        chalk.dim(this.commands[command].description)
      ]
    }))

    const examples = this.examples.length > 0 ?
      `\nExamples:\n\n${indent(this.examples.join('\n'), 2)}\n` :
      ''

    let help = `${this.pkg.description ? `\n${this.pkg.description}\n` : ''}
Usage: ${this.cliUsage}
${examples}
Commands:
github zeit / now / packages / now-cli / src / commands / dns / rm.ts View on Github external
return new Promise(resolve => {
    output.log(msg);
    output.print(
      `${table([getDeleteTableRow(domainName, record)], {
        align: ['l', 'r', 'l'],
        hsep: ' '.repeat(6)
      }).replace(/^(.*)/gm, '  $1')}\n`
    );
    output.print(
      `${chalk.bold.red('> Are you sure?')} ${chalk.gray('[y/N] ')}`
    );
    process.stdin
      .on('data', d => {
        process.stdin.pause();
        resolve(
          d
            .toString()
            .trim()
            .toLowerCase() === 'y'
        );
github zeit / now / src / providers / sh / commands / certs / ls.js View on Github external
function formatCertsTable(certsList) {
  return table([
      formatCertsTableHead(),
      ...formatCertsTableBody(certsList),
    ], {
      align: ['l', 'l', 'r', 'c', 'r'],
      hsep: ' '.repeat(2),
      stringLength: strlen
    }
  ).replace(/^(.*)/gm, '  $1') + '\n'
}
github ctx-core / ctx-core / quovo / cli.js View on Github external
function user$table() {
    return table(
      concat__array(
        [['0', '(cancel)']],
        users__quovo.map(user__quovo => row__user__quovo(user__quovo))
      ))
  }
}

text-table

borderless text tables with alignment

MIT
Latest version published 11 years ago

Package Health Score

65 / 100
Full package analysis

Popular text-table functions

Similar packages