18 lines
570 B
Nim
18 lines
570 B
Nim
import cligen, os, streams
|
|
import common
|
|
|
|
proc main(files:seq[string], lines=10, bytes=0) =
|
|
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))
|