#423·prompts

result of `format: val => ...` should reflect in the logged value

Author: nicholaswminCreated Oct 18, 2024Updated Oct 18, 2024

Hello - great work guys. loving it so far; easy, uncomplicated.

My philosophy is to keep as much leniency as possible in validate and try to "fix" user input in format. The issue is that the result of format is hidden until the very end. The entered value doesn't update so the user cant know what the values will look like until the prompt chain ends.

For example, this:

  • asks your name. Whatever you enter ,it changes it via format to "bar".
  • when you proceed to the next question asking about your age, I assume format has already run for the previous?
  • why not update the displayed answer then?

thoughts? is it possible?

javascript
  const response = await prompts([
    {
      type: 'text',
      name: 'value',
      message: 'name?',
      format: value => 'bar'
    },
    {
      type: 'number',
      name: 'age',
      message: 'age?',
      format: value => 100
    }
  ])

I've completed the 1st prompt, and I'm now filling the 2nd, the age. Yet it stil displays foo - it shouldn't since format always changes that value to bar. It should say 'bar' shouldn't it?

Can I manually "rerender" perhaps?

showing terminal output, im at 2nd prmompt filling my age