How to read from stdin with nim script?

How would I read from stdin via nimscript?

I tried:

if readLine(stdin) == "yes": exec buildCommand 

I ran the script with

 nim c build.nims 

I get

build.nims (50, 13) Error: undeclared identifier: 'stdin'

+4
source share
3 answers

I don't think nimscript only supports reading with stdin .

You may need to create a function request for this: https://github.com/nim-lang/Nim/issues

+4
source
 var f : File; discard f.open(0, fmRead) let s = f.readLine() echo "INPUT " & s 

... works - stdin has a file descriptor of 0

+2
source

Now this is implemented in nimscript in devel: readAllFromStdin() .

It will be available in Nim v0.20. 0+ (not yet released as of 2019-05-21).

+2
source

Source: https://habr.com/ru/post/1245383/


All Articles