From 86ba1645b0d8277c32e4593d275da5ffb2fca57e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 25 Apr 2020 22:03:51 +0300 Subject: [PATCH] os: add os.input(prompt) --- vlib/os/os.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/os/os.v b/vlib/os/os.v index a96d79908a..b3fc5ff46c 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -662,6 +662,13 @@ pub fn file_name(path string) string { 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 pub fn get_line() string { str := get_raw_line()