Lumesh ui
Module User Manual
Overview
The ui
module provides a set of interactive command-line interface functions that support user input of various data types (integers, floats, text, passwords, etc.) as well as option selection functionality. The calling method can use ui.function_name(arg1, arg2)
or space-separated parameters ui.function_name arg1 arg2
.
View Help
help ui |
Function List
Function Name | Description | Parameter Format | Return Type |
---|---|---|---|
int | Read integer input | <Prompt Message> |
Integer |
float | Read float input | <Prompt Message> |
Float |
text | Read text input | <Prompt Message> |
String |
passwd | Read password input | <Prompt Message> [Require Confirmation] |
String |
confirm | User confirmation (Yes/No) | <Prompt Message> |
Boolean |
pick | Single choice (select one option) | [Prompt or Config] <Option List/String> |
Any Type |
multi_pick | Multiple choice (select multiple options) | [Prompt or Config] <Option List/String> |
List |
Detailed Description of Input Functions
1. int - Read Integer Input
Get integer input from the user and validate its validity.
Syntax:
ui.int "Prompt Message" |
Example:
; Read user age |
2. float - Read Float Input
Get float input from the user and validate its validity.
Syntax:
ui.float "Prompt Message" |
Example:
; Read product price |
3. text - Read Text Input
Get a line of text input from the user.
Syntax:
ui.text "Prompt Message" |
Example:
; Read username |
4. passwd - Read Password Input
Securely read password input, with an option to require password confirmation.
Syntax:
ui.passwd "Prompt Message" [confirm?] |
Parameters:
confirm?
(optional): Boolean value, defaults to truetrue
: Requires password confirmation (input twice)false
: No confirmation needed (input once)
Example:
; Read password (requires confirmation) |
5. confirm - User Confirmation
Prompt the user to answer a Yes/No question and return a boolean value.
Syntax:
ui.confirm "Prompt Message" |
Example:
; Confirm whether to continue the operation |
Detailed Description of Selection Functions
6. pick - Single Choice
Allow the user to select one option from multiple choices.
Syntax:
ui.pick [Config|Prompt] Option List |
Parameter Format:
- Parameter 1 (optional): Configuration object or prompt string
- Type:
Map
orString
- Supported Configuration Items:
msg
: Prompt message (string)page_size
: Number of options displayed per page (integer)starting_cursor
: Initial cursor position (integer)
- Type:
- Option Data Source (choose one):
- List Expression:
list("Option1" "Option2" ...)
- Multi-line String:
"Option1\nOption2\n..."
- Multiple Parameter Form: Directly pass multiple option expressions
ui.pick Option1 Option2 ...
- List Expression:
Example:
- Simple single choice:
let color = (ui.pick "Choose a color:" ["Red", "Green", "Blue"]) |
- Using string option source:
let fruits = "Apple\nBanana\nOrange" |
- Using detailed configuration:
let oss = ["Windows", "Linux", "Mac"] |
7. multi_pick - Multiple Choice
Allow the user to select multiple options from a list.
Syntax:
ui.multi_pick [Config|Prompt] Option List |
Parameter Format:
- Parameter 1 (optional): Configuration object or prompt string
- Type:
Map
orString
- Supported Configuration Items:
msg
: Prompt message (string)page_size
: Number of options displayed per page (integer)starting_cursor
: Initial cursor position (integer)
- Type:
- Option Data Source (choose one):
- List Expression:
list("Option1" "Option2" ...)
- Multi-line String:
"Option1\nOption2\n..."
- Multiple Parameter Form: Directly pass multiple option expressions
ui.multi_pick Option1 Option2 ...
- List Expression:
Example:
fs.ls -l | ui.multi_pick "Which files do you want to delete?" |