1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00
nux-env/inc/nuxfs.dsl.inc.sh
Tony Tkacik 8267bc2e12 Moved is_function and runner.run to inc/
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2016-11-11 20:09:30 +01:00

93 lines
1.7 KiB
Bash

function exec.if.function {
FUNC_NAME=$1;
DEFAULT_NAME=$2;
shift; shift;
if nux.check.function $FUNC_NAME; then
nux.log debug Executing: $FUNC_NAME "$@";
$FUNC_NAME "$@";
return;
fi
if nux.check.function $DEFAULT_NAME; then
nux.log debug Executing: $FUNC_NAME "$@";
$DEFAULT_NAME "$@";
return;
fi
}
function nuxfs.dsl.command {
CMD=$1;
localFile=$(nuxfs.relative "$2");
shift; shift;
nux.log debug Processing $CMD "$localFile" $@;
exec.if.function $CMD.pre "$localFile" "$@";
nux.log debug Working file: $NC_White$localFile;
if nuxfs.file.exists "$localFile"; then
nux.log debug "File $localFile exits";
exec.if.function $CMD.exists def.exists "$localFile" "$@";
else
nux.log debug "File $localFile does not exists";
exec.if.function $CMD.notexists def.notexists "$localFile" "$@";
fi
exec.if.function $CMD.post def.post "$localFile" "$@";
}
function nuxfs.dsl.keywords {
origin() {
:
}
dir() {
nuxfs.dsl.command directory "$@";
}
directory() {
nuxfs.dsl.command directory "$@";
}
link() {
nuxfs.dsl.command link "$@";
#nux.log debug ln -s "$ORIGIN/$1" "$VFS/$2" ;
}
git() {
nuxfs.dsl.command git "$@";
#echo git clone $1 $2;
}
directory.post() {
nuxfs.dir.push "$1"
nux.log debug "Adding to dir stack: $1"
}
directory.exists() {
if test -d "$1"; then
nux.log debug "Directory exists '$1'"
else
nuxfs.error "$1" "is not directory."
fi
}
enddirectory() {
nuxfs.dir.pop
}
enddir() {
nuxfs.dir.pop
}
}
function nuxfs.dsl.execute {
nuxfs.dsl.keywords
declare -a DIR_ARRAY
DIR_ARRAY[0]=.
if test -f "$1"; then
source $1;
else
error "$1": Definition file does not exists.
fi
}