Cleanup.
This commit is contained in:
parent
449622cd8f
commit
82e18d29a8
1 changed files with 12 additions and 9 deletions
|
@ -1,21 +1,24 @@
|
|||
package com.example
|
||||
|
||||
import java.io.File
|
||||
import net.thauvin.erik.readingtime.ReadingTime
|
||||
import net.thauvin.erik.readingtime.ReadingTime.Companion.imgCount
|
||||
import net.thauvin.erik.readingtime.ReadingTime.Companion.wordCount
|
||||
import java.io.File
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.isNotEmpty()) {
|
||||
val text = File(args[0])
|
||||
if (text.exists() && text.canRead()) {
|
||||
val rt = ReadingTime(text.readText())
|
||||
rt.postfix = "minute to read"
|
||||
rt.plural = "minutes to read"
|
||||
with(File(args[0])) {
|
||||
if (exists() && canRead()) {
|
||||
val rt = ReadingTime(readText())
|
||||
rt.postfix = "minute to read"
|
||||
rt.plural = "minutes to read"
|
||||
|
||||
println("It will take ${rt.calcReadingTime()} ${wordCount(rt.text)} words and ${imgCount(rt.text)} images.")
|
||||
} else {
|
||||
System.err.println("The file could not be read or found.")
|
||||
println(
|
||||
"It will take ${rt.calcReadingTime()} ${wordCount(rt.text)} words and ${imgCount(rt.text)} images."
|
||||
)
|
||||
} else {
|
||||
System.err.println("The file could not be read or found.")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.err.println("Please specify a file as an argument.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue