From 99355ae8b2d9ef2cb0de9c7373777e54b65eca5a Mon Sep 17 00:00:00 2001 From: AtjonTV Date: Wed, 24 Jul 2019 18:14:13 +0200 Subject: [PATCH] os: Implement a read-all for STDIN --- vlib/os/os.v | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vlib/os/os.v b/vlib/os/os.v index 0fea036313..2a0767fd48 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -546,6 +546,34 @@ pub fn get_raw_line() string { } } +pub fn get_lines() []string { + mut line := '' + mut inputstr := []string + for { + line = get_line() + if(line.len <= 0) { + break + } + line = line.trim_space() + inputstr << line + } + return inputstr +} + +pub fn get_lines_joined() string { + mut line := '' + mut inputstr := '' + for { + line = get_line() + if(line.len <= 0) { + break + } + line = line.trim_space() + inputstr += line + } + return inputstr +} + pub fn user_os() string { $if linux { return 'linux'