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 the ability to select options. The calling format 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> [confirm required] |
String |
| confirm | User confirmation (yes/no) | <prompt message> |
Boolean |
| pick | Single choice (select one option) | [prompt or config] <options list/string> |
Any type |
| multi_pick | Multiple choice (select multiple options) | [prompt or config] <options list/string> |
List |
Input Function Detailed Description
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 confirm the password.
Syntax:
Ui.passwd "Prompt message" [confirm?] |
Parameters:
confirm?(optional): Boolean, defaults to truetrue: Requires password confirmation (input twice)false: Does not require confirmation (input once)
Example:
# Read password (requires confirmation) |
5. confirm - User Confirmation
Ask the user a yes/no question and return a boolean value.
Syntax:
Ui.confirm "Prompt message" |
Example:
# Confirm whether to continue operation |
Selection Function Detailed Description
6. pick - Single Choice
Allow the user to select one option from multiple choices.
Syntax:
Ui.pick [config|prompt] options list |
Parameter Format:
- Parameter 1 (optional): Configuration object or prompt string
- Type:
MaporString - Supported configuration items:
msg: Prompt message (string)page_size: Number of options displayed per page (integer)starting_cursor: Initial cursor position (integer)
- Type:
- Options 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", "macOS"] |
7. multi_pick - Multiple Choice
Allow the user to select multiple options from a list.
Syntax:
Ui.multi_pick [config|prompt] options list |
Parameter Format:
- Parameter 1 (optional): Configuration object or prompt string
- Type:
MaporString - Supported configuration items:
msg: Prompt message (string)page_size: Number of options displayed per page (integer)starting_cursor: Initial cursor position (integer)
- Type:
- Options 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?" |