From 3e23adf8218277c710d5a9ed711d6e1863e01f4f Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Tue, 24 Feb 2026 18:52:37 +0800 Subject: [PATCH] feat: add hello and time demo hub scripts --- scripts/hello.hub.kts | 17 +++++++++++++++++ scripts/time.hub.kts | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 scripts/hello.hub.kts create mode 100644 scripts/time.hub.kts diff --git a/scripts/hello.hub.kts b/scripts/hello.hub.kts new file mode 100644 index 0000000..ce75b3b --- /dev/null +++ b/scripts/hello.hub.kts @@ -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 = 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) diff --git a/scripts/time.hub.kts b/scripts/time.hub.kts new file mode 100644 index 0000000..b4455cb --- /dev/null +++ b/scripts/time.hub.kts @@ -0,0 +1,2 @@ +import java.time.LocalDateTime +println("time=" + LocalDateTime.now())