readline: improve README.md with working examples

pull/12360/head
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
1 changed files with 14 additions and 8 deletions

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')
``` ```