1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00

Splitted nuxfs into components.

Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
Tony Tkáčik 2016-11-11 19:55:34 +01:00
parent 6e5c5986c3
commit 531f55f249
3 changed files with 143 additions and 152 deletions

93
inc/nuxfs.dsl.inc.sh Normal file
View file

@ -0,0 +1,93 @@
function exec.if.function {
FUNC_NAME=$1;
DEFAULT_NAME=$2;
shift; shift;
if is_function $FUNC_NAME; then
nux.log debug Executing: $FUNC_NAME "$@";
$FUNC_NAME "$@";
return;
fi
if is_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
}