-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.sh
executable file
·80 lines (67 loc) · 1.31 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
#
# Basic demo of features
#
cd src || exit 2
source main.sh
cd - || exit 2
#
# Platform
#
echo "You are using the OS '$(detect_os)'"
echo "Opener for tools/links: '$(get_opener)'"
open_link "https://github.com"
#
# 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
#
ranged="$(range "foo bar" "-5" 0 5)"
options=("one" "two" "three" "four" "a" "b" "c" "d" "e")
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
range:
$ranged
editor:
$editor
"