feat: Add first modules
This adds the first modules blocks from the initial proof of concept, with basic docs. Currently missing is bundling and usage instructions
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Basic demo of features
|
||||
#
|
||||
source src/main.sh
|
||||
|
||||
#
|
||||
# UTILS
|
||||
#
|
||||
show_error "Something went wrong"
|
||||
show_success "There we go"
|
||||
|
||||
#
|
||||
# LOGGING
|
||||
#
|
||||
export LOG_LEVEL="$LOG_DEBUG"
|
||||
log "$LOG_DEBUG" "Debug message"
|
||||
log "$LOG_INFO" "Info message"
|
||||
log "$LOG_WARN" "Warn message"
|
||||
log "$LOG_ERROR" "Error message"
|
||||
|
||||
#
|
||||
# PROMPTS
|
||||
#
|
||||
|
||||
options=("one" "two" "three" "four")
|
||||
|
||||
validate_password() {
|
||||
if [ ${#1} -lt 10 ];then
|
||||
echo "Password needs to be at least 10 characters"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Password prompt
|
||||
pass=$(with_validate 'password "Enter random password"' validate_password)
|
||||
|
||||
# Checkbox
|
||||
checked=$(checkbox "Select one or more items" "${options[@]}")
|
||||
|
||||
# text input with validation
|
||||
text=$(with_validate 'input "Please enter something and confirm with enter"' validate_present)
|
||||
|
||||
# Select
|
||||
option=$(list "Select one item" "${options[@]}")
|
||||
|
||||
# Confirm
|
||||
confirmed=$(confirm "Should it be?")
|
||||
|
||||
# Open editor
|
||||
editor=$(editor "Please enter something in the editor")
|
||||
|
||||
# Print results
|
||||
echo "
|
||||
---
|
||||
password:
|
||||
$pass
|
||||
input:
|
||||
$text
|
||||
select:
|
||||
$option
|
||||
checkbox:
|
||||
$checked
|
||||
confirm:
|
||||
$confirmed
|
||||
editor:
|
||||
$editor
|
||||
"
|
||||
Reference in New Issue
Block a user