mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
Former-commit-id: 851e141fc91b170190d6027f42f59906dda0f31f Former-commit-id: 03dbb9da1788e1c50e84ae33d95f76194ad9a08d
31 lines
667 B
Kotlin
31 lines
667 B
Kotlin
package net.torvald.terrarum.console
|
|
|
|
import java.io.IOException
|
|
import java.nio.file.FileSystems
|
|
import java.nio.file.Files
|
|
|
|
/**
|
|
* Created by minjaesong on 16-02-10.
|
|
*/
|
|
internal object CatStdout : ConsoleCommand {
|
|
override fun execute(args: Array<String>) {
|
|
|
|
if (args.size == 1) {
|
|
printUsage()
|
|
return
|
|
}
|
|
|
|
try {
|
|
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ Echo(it) })
|
|
}
|
|
catch (e: IOException) {
|
|
Echo("CatStdout: could not read file -- IOException")
|
|
}
|
|
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo("usage: cat 'path/to/text/file")
|
|
}
|
|
}
|