forked from openrs2/openrs2
A future commit will introduce CLI options that need to be interpreted as an Instant. Signed-off-by: Graham <gpe@openrs2.org>bzip2
parent
f3ea8e71fe
commit
ab006bbf44
@ -0,0 +1,24 @@ |
|||||||
|
plugins { |
||||||
|
`maven-publish` |
||||||
|
kotlin("jvm") |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
api("com.github.ajalt.clikt:clikt:${Versions.clikt}") |
||||||
|
} |
||||||
|
|
||||||
|
publishing { |
||||||
|
publications.create<MavenPublication>("maven") { |
||||||
|
from(components["java"]) |
||||||
|
|
||||||
|
pom { |
||||||
|
packaging = "jar" |
||||||
|
name.set("OpenRS2 CLI") |
||||||
|
description.set( |
||||||
|
""" |
||||||
|
Clikt extensions. |
||||||
|
""".trimIndent() |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package org.openrs2.cli |
||||||
|
|
||||||
|
import com.github.ajalt.clikt.core.BadParameterValue |
||||||
|
import com.github.ajalt.clikt.parameters.options.NullableOption |
||||||
|
import com.github.ajalt.clikt.parameters.options.RawOption |
||||||
|
import com.github.ajalt.clikt.parameters.options.convert |
||||||
|
import java.time.Instant |
||||||
|
import java.time.OffsetDateTime |
||||||
|
import java.time.format.DateTimeParseException |
||||||
|
|
||||||
|
public fun RawOption.instant(): NullableOption<Instant, Instant> = convert({ "TIMESTAMP" }) { |
||||||
|
try { |
||||||
|
OffsetDateTime.parse(it).toInstant() |
||||||
|
} catch (ex: DateTimeParseException) { |
||||||
|
throw BadParameterValue("$it is not a valid timestamp") |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue