How to use the enquirer.Scale function in enquirer

To help you get started, we’ve selected a few enquirer 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 / examples / scale / option-linebreak.js View on Github external
'use strict';

const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  linebreak: true,
  scale: [
    { name: '1', message: 'Strongly Disagree' },
    { name: '2', message: 'Disagree' },
    { name: '3', message: 'Neutral' },
    { name: '4', message: 'Agree' },
    { name: '5', message: 'Strongly Agree' }
  ],
  choices: [
    {
      name: 'interface',
      message: 'A. The website has a friendly interface.',
      initial: 2
    },
github enquirer / enquirer / examples / scale / option-number.js View on Github external
'use strict';

const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  number(n) {
    let choice = prompt.focused;
    let i = +n - 1;
    if (i >= prompt.scale.length) return prompt.alert();
    choice.scaleIndex = i;
    return prompt.render();
  },
  scale: [
    { name: '1', message: 'Strongly Disagree' },
    { name: '2', message: 'Disagree' },
    { name: '3', message: 'Neutral' },
    { name: '4', message: 'Agree' },
    { name: '5', message: 'Strongly Agree' }
  ],
github enquirer / enquirer / examples / scale / prompt-stars.js View on Github external
'use strict';

const colors = require('ansi-colors');
const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  scale: 5,
  symbols: { line: ' ' },
  edgeLength: 1,
  styles: {
    primary: colors.blue
  },
  format() {
    return '';
  },
  renderScaleHeading() {
    return '';
  },
  scaleIndicator(choice, item, i) {
    let enabled = choice.scaleIndex >= item.index;
github enquirer / enquirer / examples / scale / prompt-wrapped-messages.js View on Github external
'use strict';

const colors = require('ansi-colors');
const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  messageWidth: 30,
  margin: '    ',
  edgeLength: 3,
  margin: [1, 1, 1, 0],
  styles: { primary: colors.blue },
  scale: [
    { name: '1', message: 'Strongly Disagree' },
    { name: '2', message: 'Disagree' },
    { name: '3', message: 'Neutral' },
    { name: '4', message: 'Agree' },
    { name: '5', message: 'Strongly Agree' }
  ],
  choices: [
    {
github enquirer / enquirer / examples / scale / prompt-experience.js View on Github external
'use strict';

const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'How would you rate your experience?',
  hint: '(0=bad, 10=awesome)',
  scale: 11,
  edgeLength: 2,
  choices: [
    {
      name: 'none',
      message: 'The website has a friendly interface.',
      initial: 5
    },
    {
      name: 'navigation',
      message: 'The website is easy to navigate.',
      initial: 5
    },
github enquirer / enquirer / examples / scale / prompt-checks.js View on Github external
'use strict';

const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  scale: [
    { name: '1', message: 'Strongly Disagree' },
    { name: '2', message: 'Disagree' },
    { name: '3', message: 'Neutral' },
    { name: '4', message: 'Agree' },
    { name: '5', message: 'Strongly Agree' }
  ],
  symbols: { line: ' ' },
  edgeLength: 1,
  messageWidth: 48,
  scaleIndicator(choice, item, i) {
    let enabled = choice.scaleIndex === item.index;
    if (enabled) return this.styles.success(this.symbols.check);
    if (this.index === i) return this.styles.muted(this.symbols.check);
github enquirer / enquirer / examples / scale / prompt.js View on Github external
'use strict';

const { Scale } = require('enquirer');
const prompt = new Scale({
  name: 'experience',
  message: 'Please rate your experience',
  scale: [
    { name: '1', message: 'Strongly Disagree' },
    { name: '2', message: 'Disagree' },
    { name: '3', message: 'Neutral' },
    { name: '4', message: 'Agree' },
    { name: '5', message: 'Strongly Agree' }
  ],
  margin: [0, 0, 2, 1],
  choices: [
    {
      name: 'interface',
      message: 'The website has a friendly interface.',
      initial: 2
    },