-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecklist.sh
More file actions
48 lines (41 loc) · 1.19 KB
/
checklist.sh
File metadata and controls
48 lines (41 loc) · 1.19 KB
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
#!/usr/bin/env bash
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$ROOT"/../core.sh
# This demo box is part of the main menu, so we'll use it's menu entry title for all boxes
config title="$1"
function start_checklist() {
list \
text='Hint: use space to select options in the list below' \
prefix='alphanum' \
callback='checklist_handler()'
for i in {1..10}; do
local summary='' selected='false'
if [ "$i" -eq 5 ]; then
summary='Option #5 is selected by default'
selected='true'
fi
listEntry \
title="Option #$i" \
summary="$summary" \
selected="$selected"
done
listDraw
}
function checklist_handler() {
# Capture the status code from the list box
local status=$? text
if [ $status -eq 255 ]; then # Escape key pressed
text='Exited with ESC.'
elif [ $status -eq 1 ]; then # Cancel button pressed
text='Canceled.'
elif [ $# -eq 0 ]; then
text="You didn't make any choice."
else
text="You chose:\n"
for entry; do
text+="$entry\n"
done
fi
text text="$text"
}
start_checklist