nimbase/head.nim
2019-03-27 11:49:48 +01:00

20 lines
617 B
Nim

import cligen, os, streams
import common
proc main(files:seq[string], lines=10, bytes=0) =
# if files.len == 0:
# files.add "-"
for file in files:
var s = newFileStream(file, fmRead)
if bytes > 0:
var currentByte = 0
while not s.atEnd and currentByte < bytes:
write(stdout, s.readChar)
inc currentByte
elif lines > 0:
var currentLine = 0
while not s.atEnd and currentLine < lines:
echo s.readLine
inc currentLine
dispatch(main, version=("version", nimbaseVersion))