Skip to content

Commit c66d20f

Browse files
author
marcofilho
committed
base: add help function to lnls-get-n-unpack.
Add help function to be called when arguments are not called appropriately. Add call to help function when script is called with no arguments or with '-h' option.
1 parent d7b71bf commit c66d20f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

base/lnls-get-n-unpack.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,31 @@
44

55
set -eu
66

7+
help () {
8+
echo "lnls-get-n-unpack: download and extract archive from the network"
9+
echo -e "Usage: lnls-get-n-unpack <extraction_mode> <URL1> [URL2] [...] [URLN]\n"
10+
echo "Extraction mode:"
11+
echo " -l extracts to local directory (./)"
12+
echo " -r extracts to root directory (/)"
13+
echo "URL:"
14+
echo " url to download source from."
15+
exit 0
16+
}
17+
718
check_arguments() {
819

20+
# No arguments = call help and exit.
21+
if [ "$#" -eq 0 ]; then
22+
help
23+
fi
24+
25+
# if -h is anywhere arguments list, call help and exit.
26+
for arg in "$@"; do
27+
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]; then
28+
help
29+
fi
30+
done
31+
932
case "$1" in
1033
-r) dest=/ ;;
1134
-l) dest=. ;;

0 commit comments

Comments
 (0)