diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0afe1..dfd880a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ + deleted makefile (call `./cbuild.sh` or installed `cbuild`) + added command line arguments: + `--help` + + `--version` + `--current-config` + `--default-config` + `--new-project` diff --git a/cbuild.sh b/cbuild.sh index 7d0aa87..bacd22c 100644 --- a/cbuild.sh +++ b/cbuild.sh @@ -14,7 +14,7 @@ fi function include { local script_path="$1" if [[ "$script_path" == cbuild/* ]]; then - script_path="$CBUILD_INSTALL_DIR/$(safeprint $script_path | sed 's,^cbuild/,,')" + script_path="$CBUILD_INSTALL_DIR/$(echo $script_path | sed 's,^cbuild/,,')" fi # echp "including script $script_path" . "$script_path" @@ -31,8 +31,11 @@ include "cbuild/functions.sh" include "cbuild/config.sh" function print_help_and_exit { + myprint "cbuild v$INSTALLED_CBUILD_VERSION" + myprint "C/C++ project build system written in bash." myprint "Usage: cbuild [OPTIONS] [TASK]" myprint " -h, --help Show this message" + myprint " -v, --version Shows version" myprint " -n, --new-project [PROJ_DIR] Initialize new cbuild project directory (default=./)" myprint " -c, --current-config FILE Set current config file path (default=./current.config)" myprint " -d, --default-config FILE Set default config file path (default=./current.config)" @@ -60,6 +63,10 @@ do '-h' | '--help') print_help_and_exit ;; + '-v' | '--version') + myprint $INSTALLED_CBUILD_VERSION + exit 0 + ;; '-c' | '--current-config') i=$((i+1)) current_config_path="${args[i]}" diff --git a/myprint.sh b/myprint.sh index c64c2db..e23cce9 100644 --- a/myprint.sh +++ b/myprint.sh @@ -10,15 +10,15 @@ BLUE='\033[0;94m' PURPLE='\033[0;95m' CYAN='\033[0;96m' -# prints text without new line +# prints text without special characters # use it to return string values from functions function safeprint { printf "%s" "$@" } -# prints text with new line and resets color +# prints text with special characters and resets color function myprint { - safeprint "$@${GRAY}\n" + printf "${GRAY}$@${GRAY}\n" } # print message and exit