mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
Former-commit-id: 375604da8a20a6ba7cd0a8d05a44add02b2d04f4 Former-commit-id: 287287c5920b07618174d7a7573f049d350ded66
33 lines
710 B
Kotlin
33 lines
710 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.
|
|
*/
|
|
class CatStdout : ConsoleCommand {
|
|
override fun execute(args: Array<String>) {
|
|
|
|
val echo = Echo()
|
|
|
|
if (args.size == 1) {
|
|
printUsage()
|
|
return
|
|
}
|
|
|
|
try {
|
|
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ echo.execute(it) })
|
|
}
|
|
catch (e: IOException) {
|
|
echo.execute("CatStdout: could not read file -- IOException")
|
|
}
|
|
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo().execute("usage: cat 'path/to/text/file")
|
|
}
|
|
}
|