os: add os.input(prompt)

pull/4595/head
Delyan Angelov 2020-04-25 22:03:51 +03:00
parent c73d91a8fe
commit 86ba1645b0
1 changed files with 7 additions and 0 deletions

View File

@ -662,6 +662,13 @@ pub fn file_name(path string) string {
return path.all_after(path_separator) return path.all_after(path_separator)
} }
// input returns a one-line string from stdin, after printing a prompt
pub fn input(prompt string) string {
print(prompt)
flush()
return get_line()
}
// get_line returns a one-line string from stdin // get_line returns a one-line string from stdin
pub fn get_line() string { pub fn get_line() string {
str := get_raw_line() str := get_raw_line()