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 e4ae60fdb0 nuxfs: added init and templates support.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2016-12-01 18:22:12 +01:00

101 lines
1.9 KiB
Bash

function exec.if.function {
FUNC_NAME=$1;
DEFAULT_NAME=$2;
shift; shift;
if nux.check.function $FUNC_NAME; then
nux.log trace Executing: $FUNC_NAME "$@";
$FUNC_NAME "$@";
return;
fi
if nux.check.function $DEFAULT_NAME; then
nux.log trace 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 def.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() {
:
}
name() {
:
}
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.pre() {
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'"
nux.log trace "Trying to nest into directory"
if test -e "$1/.nuxfs"; then
nux.log debug "Invoking nested nuxfs definition."
source "$1/.nuxfs";
fi;
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 -e "$1"; then
source $1;
else
nuxfs.error "$1" Definition file does not exists.
fi
}