Files
SwiftShell/SwiftShellTests/Scripts/print_linenumbers.swift
T
Kare Morstol 91abb8c47c Update test scripts.
The rest are waiting for reading and writing files to be implemented.
2015-09-08 18:06:49 +02:00

12 lines
314 B
Swift
Executable File

#!/usr/bin/env swiftshell
import SwiftShell
let result = main.stdin.read().characters.split("\n")
.enumerate().map { (linenr,line) in "line " + String(linenr+1) + ": " + String(line) }
// Swift demands we split this up.
main.stdout.write(result.joinWithSeparator("\n"))
// TODO: use .writeTo(&main.stdout)