Inquirer.js: Add support for multiline input

Created on 1 Mar 2014  路  10Comments  路  Source: SBoudrias/Inquirer.js

I would like to add support for multiple lines of text in the input type. I use the prompt for commit messages and sometimes one line is not enough. The UI could be as simple as pressing shift+enter to move to the next line of input. Feedback from the contributors is welcome and appreciated.

Most helpful comment

I know there is editor support, but is there any chance that you will also support multiline?
I prefer would prefer multiline over editor for my application.

Multiline should allow the user to enter multiple lines, and close when it encounters an empty line (or line with only a dot) or when the user presses CTRL+D.
At least that is the standard behaviour across various command line applications I use.

I tried to look at your code to implement it myself, but I don't really understand how to implement a custom prompt... Is there any documentation or tutorial?

All 10 comments

I wonder if we could call the system editor like when you git commit and get the content back afterward.

+1. karma init does this reasonably well

This would be great for doing things like blog posts from the command-line. Hexo would do well to integrate this.

Just to make sure this stays on the radar: +1

+1 Any updates on this? I support the Shift+Enter idea, either as a default to insert newline on any option, or swapped for Enter behavior which instead inserts newline on options explicitly configured as multiline.

@adjohnson916 PR welcomed.

This is now shipped with v1.1.0

I know there is editor support, but is there any chance that you will also support multiline?
I prefer would prefer multiline over editor for my application.

Multiline should allow the user to enter multiple lines, and close when it encounters an empty line (or line with only a dot) or when the user presses CTRL+D.
At least that is the standard behaviour across various command line applications I use.

I tried to look at your code to implement it myself, but I don't really understand how to implement a custom prompt... Is there any documentation or tutorial?

A working (yet untested) implementation: https://github.com/aleclarson/inquirer/commit/16ddf2f497ca7b0929ba252eef875062eebd5e64

It adds a multiline boolean option to input prompts. It probably won't merge cleanly into master, because I've made other changes. But you can take inspiration from it.

The ctrl+d key binding has its own commit: https://github.com/aleclarson/inquirer/commit/e5c844e9ab056e3b17eef94ae05dc211d0656275

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mechanical-turk picture mechanical-turk  路  3Comments

christav picture christav  路  5Comments

lvjiaxuan picture lvjiaxuan  路  6Comments

Ezekiel-DA picture Ezekiel-DA  路  7Comments

bugzpodder picture bugzpodder  路  4Comments