Hi,
I've seen #5 but this one is slightly different (at least I think so). I find the library very nice, but I'm failing at making a simple menu with 2 screens (the 2nd screen depending on the output of the 1st), which seems like a basic use of enquirer
.
So have I missed something here?
Here is my use case: I want to first ask the user for the name of an argument, and then make him chose between a predefined set of arguments (the use case for this is templating, but that doesn't matter)
Here is my code:
'use strict';
const Enquirer = require('enquirer')
const inspect = require ('util').inspect
for (let i = 3; i > 0; i--) {
let enquirer = new Enquirer ()
enquirer.register ('radio', require ('prompt-radio'))
enquirer.question ('argName', 'Name for the input argument (' + i + ')?')
enquirer.question ('argType', 'Type of argument (' + i + ')?', {
type: 'radio',
choices: ['STRING', 'INT32', 'BOOL']
})
enquirer.ask()
.then (answers => {
console.log ('Argument ' + i)
console.log (inspect (answers))
console.log ('--')
})
}
And when I run it, I've got:
? Name for the input argument (3)? Foo
? Name for the input argument (2)? Foo
? Name for the input argument (1)? Foo
? Type of argument (3)? INT32
? Type of argument (2)? INT32
? Type of argument (1)? INT32
Argument 3
{ argName: 'Foo', argType: [ 'INT32' ] }
--
Argument 2
{ argName: 'Foo', argType: [ 'INT32' ] }
--
Argument 1
{ argName: 'Foo', argType: [ 'INT32' ] }
--
I've got the first Name input for the argument (1)?
, then I answered Foo
, then I was presented the radio choice, I selected INT32
with <Space>
and when I pressed entered, it dumped all of this.
I did not have a second (and neither a third) choice. How can I achieve this?