mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
still wip modularisation, game somehow boots
This commit is contained in:
32
src/net/torvald/terrarum/modulebasegame/console/CatStdout.kt
Normal file
32
src/net/torvald/terrarum/modulebasegame/console/CatStdout.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import java.io.IOException
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user