From fb6ffc1d4fbaf60b876400a087aa0c4466bf732a Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Tue, 24 Feb 2026 23:50:48 +0800 Subject: [PATCH] refactor: remove time demo script and update hello script metadata/params --- scripts/hello.hub.kts | 20 +++++++++++--------- scripts/time.hub.kts | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 scripts/time.hub.kts diff --git a/scripts/hello.hub.kts b/scripts/hello.hub.kts index ce75b3b..c8338d7 100644 --- a/scripts/hello.hub.kts +++ b/scripts/hello.hub.kts @@ -1,17 +1,19 @@ +// @desc: hello +// @timeout: 10s +// @param: name | default=world | desc=hello | required=false +// @param: upper | default=false | desc=upper text | required=true 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 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 upper = (kv["upper"]!!).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 deleted file mode 100644 index b4455cb..0000000 --- a/scripts/time.hub.kts +++ /dev/null @@ -1,2 +0,0 @@ -import java.time.LocalDateTime -println("time=" + LocalDateTime.now())