1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

readline: improve README.md with working examples

This commit is contained in:
Delyan Angelov 2021-10-29 17:32:36 +03:00
parent d1acca3e52
commit 1785b184b9
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -6,15 +6,21 @@ from a terminal in an easy and structured manner.
The module provides an easy way to prompt the user for The module provides an easy way to prompt the user for
questions or even make a REPL or an embedded console. questions or even make a REPL or an embedded console.
Use `readline.Readline` if you want to include more
advanced features such as history or simply use
`readline.read_line('Please confirm (y/n):')` directly
for one-off user interactions.
# Usage # Usage:
```v ignore ```v
import readline { Readline } import readline
Readline.read_line('Continue?: (y/n)') mut r := readline.Readline{}
answer := r.read_line('hello: ') ?
println(answer)
```
or just:
```v
import readline { read_line }
input := read_line('What is your name: ') ?
println('Your name is: $input')
``` ```