Skip to content

Commit 0ba44f3

Browse files
authored
Merge pull request #259 from DavideAG/dag-man
A new elegant whiptail based documentation script for polycube
2 parents 4f237e7 + d72f3d9 commit 0ba44f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

scripts/man.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
shopt -s -o nounset
3+
4+
count=0
5+
W=()
6+
_script="$(readlink -f ${BASH_SOURCE[0]})"
7+
_dir="$(dirname $_script)/../Documentation/services"
8+
filenames=$(ls $_dir | grep -I "pcn-*")
9+
10+
#det current screen dimensions
11+
read -r WHIP_SIZE_Y WHIP_SIZE_X < <(stty size)
12+
13+
for filename in $filenames
14+
do
15+
W+=($count "$filename")
16+
let "count++"
17+
done
18+
19+
CONTENT_SIZE=$((WHIP_SIZE_Y-9))
20+
OPTION=$(whiptail --title "Welcome to Polycube documentation" --menu "Choose a service. Full documentation at https://polycube-network.readthedocs.io/en/latest/index.html#" $WHIP_SIZE_Y $WHIP_SIZE_X $CONTENT_SIZE "${W[@]}" 3>&1 1>&2 2>&3)
21+
22+
exitstatus=$?
23+
if [ $exitstatus = 0 ]; then
24+
count=0
25+
for dir in ${filenames[@]}
26+
do
27+
if [ $count = $OPTION ]; then
28+
whiptail --textbox --scrolltext ${_dir}/${dir}/${dir:4}.rst $WHIP_SIZE_Y $WHIP_SIZE_X
29+
break
30+
else
31+
let "count++"
32+
fi
33+
done
34+
fi

0 commit comments

Comments
 (0)