enthus1ast
enthus1ast

Reputation: 2109

How to read from the stdin with nim script?

How would i read from the stdin via nimscript?

i've tried:

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

i've run the script with

nim c build.nims

i receive

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

Upvotes: 6

Views: 2914

Answers (3)

genotrance
genotrance

Reputation: 413

This is now implemented in nimscript in devel: readAllFromStdin().

It will be available in Nim v0.20.0+ (yet to be released as of 2019-05-21).

Upvotes: 3

shaunc
shaunc

Reputation: 5611

var f : File;
discard f.open(0, fmRead)

let s = f.readLine()
echo "INPUT " & s

... works -- stdin has file handle 0

Upvotes: 2

dom96
dom96

Reputation: 1022

I don't think nimscript supports reading from stdin just yet.

You might want to create a feature request for this: https://github.com/nim-lang/Nim/issues

Upvotes: 4

Related Questions