mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
nuxfs: Added macro support.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
7479fb53f8
commit
6ec235ce19
4 changed files with 45 additions and 17 deletions
|
|
@ -3,3 +3,7 @@
|
||||||
.entered() {
|
.entered() {
|
||||||
nux.dsl.info "$rel_path" $keyword
|
nux.dsl.info "$rel_path" $keyword
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.check() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ sdir() {
|
||||||
.allways.preprocess() {
|
.allways.preprocess() {
|
||||||
abs_path=$(realpath -Lms "$NUXFS_DEF_DIR/$path");
|
abs_path=$(realpath -Lms "$NUXFS_DEF_DIR/$path");
|
||||||
rel_path=$(realpath -Lms "$abs_path" --relative-base="$WORKDIR");
|
rel_path=$(realpath -Lms "$abs_path" --relative-base="$WORKDIR");
|
||||||
|
def_path=$(realpath -Lms "$path" --relative-to="$NUXFS_DEF_DIR")
|
||||||
}
|
}
|
||||||
|
|
||||||
.check() {
|
.check() {
|
||||||
|
|
@ -28,6 +29,17 @@ sdir() {
|
||||||
nux.check.file.exists "$abs_path"
|
nux.check.file.exists "$abs_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.check.failed() {
|
||||||
|
if [ -z "$NUXFS_IGNORE_MISSING" ]; then
|
||||||
|
nux.dsl.error "$rel_path" does not exists.
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
dir.entered() {
|
||||||
|
if nux.check.file.exists "$abs_path/.nuxfs"; then
|
||||||
|
source "$abs_path/.nuxfs"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
should-not-exists.check() {
|
should-not-exists.check() {
|
||||||
nux.log trace "Checking existence of $NC_White$abs_path$NC_No"
|
nux.log trace "Checking existence of $NC_White$abs_path$NC_No"
|
||||||
if nux.check.file.exists "$abs_path"; then
|
if nux.check.file.exists "$abs_path"; then
|
||||||
|
|
@ -41,12 +53,3 @@ should-not-exists.check.failed() {
|
||||||
nux.dsl.error $f Should not exists, but is present.
|
nux.dsl.error $f Should not exists, but is present.
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
.check.failed() {
|
|
||||||
nux.dsl.error "$rel_path" does not exists.
|
|
||||||
}
|
|
||||||
dir.entered() {
|
|
||||||
if nux.check.file.exists "$abs_path/.nuxfs"; then
|
|
||||||
source "$abs_path/.nuxfs"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -74,3 +74,15 @@ function nux.eval {
|
||||||
nux.log trace Going to evaluate "$@"
|
nux.log trace Going to evaluate "$@"
|
||||||
eval "$@"
|
eval "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nux.exec.optional {
|
||||||
|
local FUNC="$1"; shift;
|
||||||
|
if nux.check.function $FUNC; then
|
||||||
|
nux.log trace Executing optional: ${NC_White}${FUNC}${NC_No} "$@";
|
||||||
|
$FUNC "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function nux.dirty.urlencode {
|
||||||
|
echo -n "$1" | sed "s/ /%20/g"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,17 +55,12 @@ function nux.dsl.keyword.exec {
|
||||||
local ALLWAYS_NAME=.allways$func;
|
local ALLWAYS_NAME=.allways$func;
|
||||||
|
|
||||||
shift; shift;
|
shift; shift;
|
||||||
if nux.check.function $ALLWAYS_NAME; then
|
nux.exec.optional $ALLWAYS_NAME "$@";
|
||||||
nux.log trace Executing: $NC_White$ALLWAYS_NAME$NC_No "$@";
|
|
||||||
$ALLWAYS_NAME "$@";
|
|
||||||
fi
|
|
||||||
if nux.check.function $FUNC_NAME; then
|
if nux.check.function $FUNC_NAME; then
|
||||||
nux.log trace Executing: $NC_White$FUNC_NAME$NC_No "$@";
|
nux.exec.optional $FUNC_NAME "$@";
|
||||||
$FUNC_NAME "$@";
|
|
||||||
return $?;
|
return $?;
|
||||||
elif nux.check.function $DEFAULT_NAME; then
|
elif nux.check.function $DEFAULT_NAME; then
|
||||||
nux.log trace Executing: $NC_White$DEFAULT_NAME$NC_No "$@";
|
nux.exec.optional $DEFAULT_NAME "$@";
|
||||||
$DEFAULT_NAME "$@";
|
|
||||||
return $?;
|
return $?;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -186,6 +181,20 @@ function nux.dsl.execute {
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.macro() {
|
||||||
|
local keyword=$1
|
||||||
|
nux.log trace Defining macro $NC_White"$keyword"
|
||||||
|
nux.eval """
|
||||||
|
${keyword}() {
|
||||||
|
$(.arg.parser "$@")
|
||||||
|
nux.exec.optional ${keyword}.entered \"\$@\"
|
||||||
|
}
|
||||||
|
end${keyword}() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
.keyword.virtual() {
|
.keyword.virtual() {
|
||||||
local keyword=$1
|
local keyword=$1
|
||||||
.keyword "$@"
|
.keyword "$@"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue