feat: add hello and time demo hub scripts
This commit is contained in:
17
scripts/hello.hub.kts
Normal file
17
scripts/hello.hub.kts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
|
// @desc: Demo greeting API
|
||||||
|
// @param: name | default=world | desc=Name to greet
|
||||||
|
// @param: upper | default=false | desc=Uppercase output
|
||||||
|
|
||||||
|
val args: Array<String> = emptyArray()
|
||||||
|
val kv = args.mapNotNull {
|
||||||
|
val idx = it.indexOf('=')
|
||||||
|
if (idx <= 0) null else it.substring(0, idx) to it.substring(idx + 1)
|
||||||
|
}.toMap()
|
||||||
|
|
||||||
|
val name = kv["name"] ?: "world"
|
||||||
|
val upper = (kv["upper"] ?: "false").toBoolean()
|
||||||
|
val message = "Hello, $name @ ${LocalDateTime.now()}"
|
||||||
|
|
||||||
|
println(if (upper) message.uppercase() else message)
|
||||||
2
scripts/time.hub.kts
Normal file
2
scripts/time.hub.kts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import java.time.LocalDateTime
|
||||||
|
println("time=" + LocalDateTime.now())
|
||||||
Reference in New Issue
Block a user