From bba72ab9eb84d1fa1c484e4bfb9b9532c90ddcba Mon Sep 17 00:00:00 2001 From: Riceball LEE Date: Wed, 28 Aug 2024 10:04:17 +0800 Subject: [PATCH] feat(lib): add input WIP --- lib/input.ai.yaml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/input.ai.yaml diff --git a/lib/input.ai.yaml b/lib/input.ai.yaml new file mode 100644 index 0000000..156a2f4 --- /dev/null +++ b/lib/input.ai.yaml @@ -0,0 +1,38 @@ +--- +version: 0.1.0 +type: lib +description: |- + This script will wait for user input. +tag: + - user + - input + - lib +input: + - inputType # The input type: confirm, select, number, list, input, password + - question # the message to show to the user + - value # the initial(default) value of the input +output: + type: 'object' + properties: + question: {type: 'string'} + answer: {type: 'string'} +--- +- !fn |- + toText(value) { + if (value == null) { + return 'null'; + } + + if (typeof this.format === 'function') { + return this.format(value); + } + const t = typeof value; + switch (t) { + case 'boolean': + return value ? 'yes' : 'no'; + } + return value + } +- $set: + result: $consoleInput +- $echo: "result.answer"