From 6d300063680aa11919b13a3fc951ad2cf8820fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Mon, 29 Jan 2024 15:49:41 +0100 Subject: [PATCH] Use case instead of several if statements --- qsgen2 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/qsgen2 b/qsgen2 index 5f042d8..8ad2b2d 100755 --- a/qsgen2 +++ b/qsgen2 @@ -70,17 +70,26 @@ include common/colors echo "${magenta}${QSGEN} ${VERSION}${end}" -if [[ ${1} == "version" ]] || [[ ${1} == "-v" ]] || [[ ${1} == "--version" ]]; then - echo "${yellow}- Created by kekePower - 2018-2024${end}" +function _version() { + echo "${yellow}- Created by kekePower - 2018-$(date +%Y)${end}" echo "${yellow}- https://github.com/kekePower/qsgen2/${end}" echo "${yellow}- See '${0:t} help' for more information." exit -fi +} -if [[ ${1} == "help" ]]; then - echo "This is where I'll write the Help documentation." +function _help() { + echo "This is where I'll write the Help documentation." exit -fi +} + +case ${1} in + version || -v || --version) + _version + ;; + help || -h || --help) + _help + ;; +esac # Loading Zsh modules zmodload zsh/files