fixed myprint and added --version
This commit is contained in:
parent
9b1bbffbc4
commit
0ebc1c47ee
@ -3,6 +3,7 @@
|
|||||||
+ deleted makefile (call `./cbuild.sh` or installed `cbuild`)
|
+ deleted makefile (call `./cbuild.sh` or installed `cbuild`)
|
||||||
+ added command line arguments:
|
+ added command line arguments:
|
||||||
+ `--help`
|
+ `--help`
|
||||||
|
+ `--version`
|
||||||
+ `--current-config`
|
+ `--current-config`
|
||||||
+ `--default-config`
|
+ `--default-config`
|
||||||
+ `--new-project`
|
+ `--new-project`
|
||||||
|
|||||||
@ -14,7 +14,7 @@ fi
|
|||||||
function include {
|
function include {
|
||||||
local script_path="$1"
|
local script_path="$1"
|
||||||
if [[ "$script_path" == cbuild/* ]]; then
|
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
|
fi
|
||||||
# echp "including script $script_path"
|
# echp "including script $script_path"
|
||||||
. "$script_path"
|
. "$script_path"
|
||||||
@ -31,8 +31,11 @@ include "cbuild/functions.sh"
|
|||||||
include "cbuild/config.sh"
|
include "cbuild/config.sh"
|
||||||
|
|
||||||
function print_help_and_exit {
|
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 "Usage: cbuild [OPTIONS] [TASK]"
|
||||||
myprint " -h, --help Show this message"
|
myprint " -h, --help Show this message"
|
||||||
|
myprint " -v, --version Shows version"
|
||||||
myprint " -n, --new-project [PROJ_DIR] Initialize new cbuild project directory (default=./)"
|
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 " -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)"
|
myprint " -d, --default-config FILE Set default config file path (default=./current.config)"
|
||||||
@ -60,6 +63,10 @@ do
|
|||||||
'-h' | '--help')
|
'-h' | '--help')
|
||||||
print_help_and_exit
|
print_help_and_exit
|
||||||
;;
|
;;
|
||||||
|
'-v' | '--version')
|
||||||
|
myprint $INSTALLED_CBUILD_VERSION
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
'-c' | '--current-config')
|
'-c' | '--current-config')
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
current_config_path="${args[i]}"
|
current_config_path="${args[i]}"
|
||||||
|
|||||||
@ -10,15 +10,15 @@ BLUE='\033[0;94m'
|
|||||||
PURPLE='\033[0;95m'
|
PURPLE='\033[0;95m'
|
||||||
CYAN='\033[0;96m'
|
CYAN='\033[0;96m'
|
||||||
|
|
||||||
# prints text without new line
|
# prints text without special characters
|
||||||
# use it to return string values from functions
|
# use it to return string values from functions
|
||||||
function safeprint {
|
function safeprint {
|
||||||
printf "%s" "$@"
|
printf "%s" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# prints text with new line and resets color
|
# prints text with special characters and resets color
|
||||||
function myprint {
|
function myprint {
|
||||||
safeprint "$@${GRAY}\n"
|
printf "${GRAY}$@${GRAY}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# print message and exit
|
# print message and exit
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user