mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 22:14:05 +09:00
Object-ified console commands (singleton!)
Former-commit-id: d04fc939a659fc4a6b952d64894bd28edf97bc38 Former-commit-id: 6c20526f3bdda2d9d08dc156b3b0fe271e89bffb
This commit is contained in:
@@ -7,26 +7,24 @@ import java.nio.file.Files
|
||||
/**
|
||||
* Created by minjaesong on 16-02-10.
|
||||
*/
|
||||
class CatStdout : ConsoleCommand {
|
||||
internal object 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) })
|
||||
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ Echo.execute(it) })
|
||||
}
|
||||
catch (e: IOException) {
|
||||
echo.execute("CatStdout: could not read file -- IOException")
|
||||
Echo.execute("CatStdout: could not read file -- IOException")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("usage: cat 'path/to/text/file")
|
||||
Echo.execute("usage: cat 'path/to/text/file")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user