Compare commits
No commits in common. "e11d3ead979d45b921246655e22b9eb46f5e46ca" and "c46346cddd1d7ba8d3c31573ab00c789c24af7d4" have entirely different histories.
e11d3ead97
...
c46346cddd
4 changed files with 14 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -39,4 +39,3 @@ build
|
||||||
/de/jotoho/
|
/de/jotoho/
|
||||||
/META-INF
|
/META-INF
|
||||||
/.idea
|
/.idea
|
||||||
*.zst
|
|
||||||
|
|
|
@ -6,9 +6,6 @@ plugins {
|
||||||
|
|
||||||
// Apply the application plugin to add support for building a CLI application in Java.
|
// Apply the application plugin to add support for building a CLI application in Java.
|
||||||
application
|
application
|
||||||
|
|
||||||
// For generating fat jars
|
|
||||||
id("com.github.johnrengelman.shadow") version "latest.release"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "de.jotoho"
|
group = "de.jotoho"
|
||||||
|
@ -42,16 +39,6 @@ tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
"Implementation-Title" to "waituntil",
|
|
||||||
"Implementation-Version" to "${project.version}",
|
|
||||||
"Main-Class" to "de.jotoho.waituntil.StartKt"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions.jvmTarget = "16"
|
kotlinOptions.jvmTarget = "16"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,13 @@ import kotlin.system.exitProcess
|
||||||
// See README.md and LICENSE.md for license information
|
// See README.md and LICENSE.md for license information
|
||||||
// Author: Jonas Tobias Hopusch (@jotoho)
|
// Author: Jonas Tobias Hopusch (@jotoho)
|
||||||
|
|
||||||
|
|
||||||
val langGerman: String = Locale.GERMAN.language
|
val langGerman: String = Locale.GERMAN.language
|
||||||
val applicationOutputLanguage: String = if (Locale.getDefault().language.equals(Locale.GERMAN.language))
|
val applicationOutputLanguage: String = if (Locale.getDefault().language.equals(Locale.GERMAN.language))
|
||||||
Locale.GERMAN.language
|
Locale.GERMAN.language
|
||||||
else Locale.ENGLISH.language
|
else Locale.ENGLISH.language
|
||||||
|
|
||||||
// For accessing package information
|
|
||||||
object DummyClass
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val optionDictionary = mapOf(Pair("-h", "--help"), Pair("-v", "--version"))
|
val optionDictionary = mapOf(Pair("-h", "--help"))
|
||||||
|
|
||||||
val options = HashSet<String>()
|
val options = HashSet<String>()
|
||||||
val words = HashSet<String>()
|
val words = HashSet<String>()
|
||||||
|
@ -25,12 +21,14 @@ fun main(args: Array<String>) {
|
||||||
for (arg in args) {
|
for (arg in args) {
|
||||||
if (arg.startsWith("--")) {
|
if (arg.startsWith("--")) {
|
||||||
options.add(arg.substring(startIndex=2))
|
options.add(arg.substring(startIndex=2))
|
||||||
} else if (arg.startsWith('-')) {
|
}
|
||||||
|
else if (arg.startsWith('-')) {
|
||||||
if (optionDictionary.containsKey(arg))
|
if (optionDictionary.containsKey(arg))
|
||||||
options.add(optionDictionary[arg]!!.substring(startIndex=2))
|
options.add(optionDictionary[arg]!!.substring(startIndex=2))
|
||||||
else
|
else
|
||||||
System.err.println("Short-hand '$arg' does not exist. Ignoring!")
|
System.err.println("Short-hand '$arg' does not exist. Ignoring!")
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
words.add(arg)
|
words.add(arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,18 +39,12 @@ fun main(args: Array<String>) {
|
||||||
println("Help is yet to come. (Not implemented)")
|
println("Help is yet to come. (Not implemented)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (options.contains("version")) {
|
|
||||||
when (applicationOutputLanguage) {
|
|
||||||
langGerman -> {
|
|
||||||
val thisPackage = DummyClass.javaClass.`package`
|
|
||||||
val appVersion = thisPackage.implementationVersion ?: "UNKNOWN"
|
|
||||||
println("waituntil version $appVersion")
|
|
||||||
}
|
}
|
||||||
}
|
else if (words.size == 1) {
|
||||||
} else if (words.size == 1) {
|
|
||||||
val target = calculateAndAnnounceTargetTime(words.iterator().next())
|
val target = calculateAndAnnounceTargetTime(words.iterator().next())
|
||||||
waitUntilTimeStamp(target)
|
waitUntilTimeStamp(target)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
when (applicationOutputLanguage) {
|
when (applicationOutputLanguage) {
|
||||||
langGerman -> System.err.println("FATAL: Es wurde exact ein nicht-flag Argument erwartet. (${words.size} erhalten)")
|
langGerman -> System.err.println("FATAL: Es wurde exact ein nicht-flag Argument erwartet. (${words.size} erhalten)")
|
||||||
else -> {
|
else -> {
|
|
@ -6,7 +6,7 @@ import java.time.LocalTime
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.time.format.FormatStyle
|
import java.time.format.FormatStyle
|
||||||
import java.util.*
|
import java.util.TimeZone
|
||||||
|
|
||||||
fun calculateAndAnnounceTargetTime(userTimeInputRaw: String): ZonedDateTime {
|
fun calculateAndAnnounceTargetTime(userTimeInputRaw: String): ZonedDateTime {
|
||||||
val userTimeInputRelative = LocalTime.parse(userTimeInputRaw)
|
val userTimeInputRelative = LocalTime.parse(userTimeInputRaw)
|
||||||
|
|
Loading…
Reference in a new issue