How to use the ansi-colors.dim function in ansi-colors

To help you get started, we’ve selected a few ansi-colors 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 enquirer / enquirer / prompts / multiselect.js View on Github external
render() {
    this.clear();
    const values = this.selected.map(choice => cyan(choice.message));
    const value = this.answered ? values.join(', ') : dim(this.hint);

    // ? render the prompt message
    let message = this.renderMessage(value);

    // - render the list of choices
    if (!this.answered) {
      message += this.renderChoices();

      if (this.choices.length > this.list.length || this.options.footer) {
        message += '\n' + gray(this.footer.trim());
      }
    }

    // > write the prompt
    this.write(message);
  }
github enquirer / enquirer / test / prompt.select.js View on Github external
prompt.once('run', async() => {
        try {
          let { state, symbols } = prompt;
          let pointer = cyan(symbols.pointer);
          let hint = dim('(this is a hint)');
          let expected = `${pointer} ${cyan.underline('A')}\n  BB ${hint}\n  CCC\n  DDDD`;
          let actual = await prompt.renderChoices();
          assert.equal(actual, expected);
          await prompt.submit();
        } catch (err) {
          cb(err);
        }
      });
github enquirer / enquirer / examples / select / choices-separators.js View on Github external
'use strict';

const colors = require('ansi-colors');
const { Select } = require('enquirer');

const prompt = new Select({
  name: 'separator-example',
  message: 'Pick your favorite color',
  choices: [
    'apple',
    'grape',
    { role: 'separator', value: colors.dim('────') },
    'watermelon',
    'cherry',
    'strawberry',
    { role: 'separator', value: colors.dim('────') },
    'lemon',
    'orange'
  ]
});

prompt.run()
  .then(answer => console.log('Answer:', answer))
  .catch(console.error);
github enquirer / enquirer / docs / run.js View on Github external
function readFiles(dir) {
  let files = fs.readdirSync(dir, { withFileTypes: true });
  let choices = [];
  for (let obj of files) {
    if (obj.name === 'support' || obj.name === 'node_modules') continue;
    let choice = { name: obj.name, value: path.join(dir, obj.name) };
    if (obj.isDirectory()) {
      choice.role = 'heading';
      choice.name = colors.dim(choice.name + '/');
      let res = readFiles(choice.value);
      if (res.length) {
        choice.choices = res;
        choices.push(choice);
      }
    } else if (choice.name.endsWith('.md')) {
      let buf = fs.readFileSync(choice.value);
      let file = { ...obj };
      file.contents = buf;
      file.comment = tokenize(buf.toString(), { stripStars: false });
      file.comment.examples = file.comment.examples
        .filter(e => hasPrompt(e.value))
        .filter(e => /^(\*\*|
github enquirer / enquirer / recipes / lazy-choices.js View on Github external
constructor(options = {}) {
    super(options);
    this.hint = options.hint || '';
    this.footer = dim('(Scroll up and down to reveal more choice)');
    this.queue = [].concat(this.options.choices || []);
    this.choices = [];
    this.cursor = 0;
    this.spin = value => {
      return spin(this.output, value, ' ' + value).then(() => value);
    };
  }
github enquirer / enquirer / lib / utils / interpolate.js View on Github external
continue;
      }

      if (token.type === 'template') {
        let choice = choices.find(ch => ch.name === key);
        let val = [choice.input, state.values[choice.value], choice.value, value].find(v => !!v);

        if (state.answered) {
          let result = format(state.values[key], choice, state);
          state.output += colors.unstyle(result);
          continue;
        }

        if (val !== value) {
          state.values[key] = val;
          value = colors.dim(val);

        } else {
          state.values[key] = '';
          val = `<${token.inner}>`;

          if (state.missing.has(key) || state.invalid.has(key)) {
            value = colors.red(val);
          } else {
            value = colors.cyan(val);
          }
        }

        if (index === state.index) {
          value = colors.underline(value);
        }
github ionic-team / stencil / src / sys / node / node-logger.ts View on Github external
}

    let filePath = diagnostic.relFilePath;
    if (typeof filePath !== 'string') {
      filePath = diagnostic.absFilePath;
    }

    if (typeof filePath === 'string') {
      if (header.length > 0) {
        header += ': ';
      }

      header += color.cyan(filePath);

      if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > -1) {
        header += color.dim(`:`);
        header += color.yellow(`${diagnostic.lineNumber}`);

        if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > -1) {
          header += color.dim(`:`);
          header += color.yellow(`${diagnostic.columnNumber}`);
        }
      }
    }

    if (header.length > 0) {
      outputLines.unshift(INDENT + header);
    }

    outputLines.push('');

    if (diagnostic.lines && diagnostic.lines.length) {
github padloc / padloc / packages / server / src / repl.ts View on Github external
function displayOrgItem(org: Org) {
    const owner = org.members.find(m => m.role === OrgRole.Owner);
    const sub = org.billing && org.billing.subscription;
    const planName = sub ? sub.plan.name : "none";
    const planType = sub ? sub.plan.type : undefined;
    return [
        colors.bold(col(org.name, 20)),
        col((owner && owner.email) || "N/A", 25),
        col(format(org.created, "yyyy-MM-dd"), 12),
        col(org.members.length, 7),
        col(org.groups.length, 7),
        col(org.vaults.length, 7),
        colors.bold[planColor(planType)](col(planName, 15)),
        colors.bold[subColor(sub)](col(subLabel(sub), 20)),
        colors.dim(org.id),
        org.frozen ? colors.red.bold("frozen") : ""
    ].join(" ");
}

ansi-colors

Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis