( text: string = "Input text" )
| 248 | * Function to get user's input from the CLI |
| 249 | */ |
| 250 | export async function getUserInput( |
| 251 | text: string = "Input text" |
| 252 | ): Promise<string> { |
| 253 | const rl = readline.createInterface({ |
| 254 | input: process.stdin, |
| 255 | output: process.stdout, |
| 256 | }); |
| 257 | |
| 258 | let user_input: string = ""; |
| 259 | |
| 260 | console.log(text); |
| 261 | |
| 262 | for await (const ui of rl) { |
| 263 | user_input = ui; |
| 264 | |
| 265 | rl.close(); |
| 266 | } |
| 267 | |
| 268 | return user_input; |
| 269 | } |