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