#!/bin/bash
# -- ABOUT THIS PROGRAM: ------------------------------------------------------
#
# Author: fang
# Version: 1.0.0
# Description: description goes here
#
# ------------------------------------------------------------------------------
# | VARIABLES |
# ------------------------------------------------------------------------------
VERSION="1.0.0"
# ------------------------------------------------------------------------------
# | UTILS |
# ------------------------------------------------------------------------------
log_dbg() {
printf "$(tput setaf 3)→ %s$(tput sgr0)\n" "$@"
}
log_svc() {
printf "$(tput setaf 76)✔ %s$(tput sgr0)\n" "$@"
}
log_err() {
printf "$(tput setaf 1)✖ %s$(tput sgr0)\n" "$@"
}
# ------------------------------------------------------------------------------
# | MAIN FUNCTIONS |
# ------------------------------------------------------------------------------
usage() {
cat <<EOF
------------------------------------------------------------------------------
| DESCRIPTION
------------------------------------------------------------------------------
Usage: $0 [options]
Example: $0
Options:
-h, --help output program instructions
-v, --version output program version
EOF
}
version() {
echo "$0: v$VERSION"
}
run() {
# your code goes here
log_dbg "log_dbg"
log_svc "log_svc"
log_err "log_err"
}
# ------------------------------------------------------------------------------
# | INITIALIZE PROGRAM |
# ------------------------------------------------------------------------------
main() {
if [[ "${1}" == "-h" || "${1}" == "--help" ]]; then
usage ${1}
exit 1
elif [[ "${1}" == "-v" || "${1}" == "--version" ]]; then
version ${1}
exit 1
else
run
fi
}
# Initialize
main $*
'쉘스크립트' 카테고리의 다른 글
[Shell Script] backfill 작업 수행 스크립트 (0) | 2021.04.22 |
---|---|
[Shell Script] 디버깅 (0) | 2021.04.15 |
[Shell Script] trap을 이용한 signal 처리방법 (0) | 2021.04.15 |
[Shell Script] 함수(function) (0) | 2021.04.15 |
[Shell Script] 반복문(while) (0) | 2021.04.15 |