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:
parent
d1acca3e52
commit
1785b184b9
@ -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')
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user