posted by 귀염둥이채원 2021. 4. 15. 17:22

#!/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 $*