GithubHelp home page GithubHelp logo

Comments (2)

ro31337 avatar ro31337 commented on September 3, 2024

Example that works (app.js):

import Log from './log';
import './init';
import inquirer from 'inquirer';

const log = new Log();
log.debug(__('app.welcome_banner'));

const choices = [];
choices.push({ name: 'Foo', value: 1 });
choices.push({ name: 'Bar', value: 2 });

inquirer.prompt([
  {
    type: 'list',
    name: 'blabla', // result hash property
    message: 'Select something maybe?',
    choices: choices
  }
]).then((result) => {
  console.log(result);
});

Result:

step 1:

? Select something maybe? (Use arrow keys)
  Foo
❯ Bar

Click ENTER above ^^^

step 2:

? Select something maybe? Bar
{ blabla: 2 }

from libretaxi.

ro31337 avatar ro31337 commented on September 3, 2024

Show list of options:

import Log from './log';
import './init';
import OptionsResponseHandler from './response-handlers/cli/options-response-handler';
import OptionsResponse from './responses/options-response';

const log = new Log();
log.debug(__('app.welcome_banner'));

const h = new OptionsResponseHandler({
  response: new OptionsResponse({
    rows: [
        [{ label: 'One', value: '1' },{ label: 'Two', value: '2' },{ label: 'Three', value: '3' }],
        [{ label: 'OK', value: 'ok' },{ label: 'Cancel', value: 'cancel' }]
    ]
  })
});

h.call();

Result:

? Your choice? (Use arrow keys)
❯ One
  Two
  Three
  OK
  Cancel

from libretaxi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.