-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputmenu.sh
More file actions
34 lines (27 loc) · 926 Bytes
/
inputmenu.sh
File metadata and controls
34 lines (27 loc) · 926 Bytes
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
#!/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"
menu \
text='Please, select an option or rename. Press ESC to exit' \
rename='true'
menuEntry \
title='Apple' \
summary='Amount: 30'
menuEntry \
title='Mango' \
summary='Amount: 5'
menuEntry \
title='Grape' \
summary='Amount: 7'
result="$(menuDraw)"; code=$?
if [ $code -eq 0 ]; then # The user selected the entry without making any changes
text text="You selected: $result"
elif [ $code -eq 3 ]; then # After renaming the exit code is equal to 3
# Strip off the prefix from the output, which is in format: RENAMED <entry> <summary>
result="${result#RENAMED }"
entry="${result%% *}"
summary="${result#* }"
text text="You've changed $entry to $summary"
fi