mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-12 13:34:29 +01:00
nux.cfg: Introduced configuration engine.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
89010fd209
commit
613ef65f67
4 changed files with 194 additions and 33 deletions
|
|
@ -38,11 +38,10 @@
|
|||
|
||||
readonly NUX_RUNNER_BIN_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
|
||||
source $NUX_RUNNER_BIN_DIR/../inc/nux-base.inc.sh
|
||||
|
||||
|
||||
readonly NUX_RUNNER=$NUX_RUNNER_BIN_DIR/nux-runner;
|
||||
|
||||
nux.include nux-runner
|
||||
nux.use nux-runner
|
||||
nux.use nux.cfg
|
||||
|
||||
##
|
||||
## Additional commands provided by *nux-runner*:
|
||||
|
|
@ -90,7 +89,15 @@ task.help() {
|
|||
### local, global, dist
|
||||
###
|
||||
task.config() {
|
||||
nux.notimplemented task.config
|
||||
nux.log trace "global is" $(nux.cfg.dir.global)
|
||||
nux.log trace "dist is" $(nux.cfg.dir.dist)
|
||||
nux.log trace "local is" $(nux.cfg.dir.local)
|
||||
|
||||
if [ "$#" -ge 3 ] ; then
|
||||
nux.cfg.write "$@"
|
||||
else
|
||||
nux.cfg.read "$@";
|
||||
fi
|
||||
}
|
||||
|
||||
task.() {
|
||||
|
|
|
|||
24
bin/nuxfs
24
bin/nuxfs
|
|
@ -134,9 +134,9 @@ function task.init {
|
|||
nux.log debug "User specified template is " $TEMPLATE
|
||||
if [ $(echo $TEMPLATE | grep -c "$SUFFIX\$") -eq 0 ]; then
|
||||
nux.log debug "Template is common template."
|
||||
TEMPLATE=$TEMPLATE_DIR/$TEMPLATE$SUFFIX
|
||||
if [ ! -e $TEMPLATE ]; then
|
||||
echo -n "Template '$1' does not exists. "
|
||||
TEMPLATE=$(nux.cfg.get.path --first templates/${TEMPLATE}${SUFFIX})
|
||||
if [ -z $TEMPLATE ]; then
|
||||
echo "Template '$1' does not exists. "
|
||||
nuxfs.template.list
|
||||
return;
|
||||
fi;
|
||||
|
|
@ -150,8 +150,8 @@ function task.init {
|
|||
local template_relative=$(realpath -Lms $TEMPLATE --relative-to $(pwd))
|
||||
nux.log debug "Creating link $SUFFIX: target is '$template_relative'";
|
||||
ln -s "$template_relative" "$SUFFIX"
|
||||
nux.log debug "Invoking create task."
|
||||
task.create
|
||||
nux.log debug "Invoking apply task."
|
||||
nuxr.run apply
|
||||
}
|
||||
|
||||
## template - List available templates
|
||||
|
|
@ -237,15 +237,11 @@ function task.capture {
|
|||
}
|
||||
|
||||
function nuxfs.template.list {
|
||||
echo "Available templates:";
|
||||
pushd $TEMPLATE_DIR > /dev/null;
|
||||
for i in $TEMPLATE_FILTER; do
|
||||
local TEMPLATE_ID=$(basename $i $SUFFIX)
|
||||
echo -n " $TEMPLATE_ID - " ;
|
||||
grep -m1 "^name " $i | sed -e "s/name *//"
|
||||
echo
|
||||
done;
|
||||
popd > /dev/null;
|
||||
nux.log trace "Templates folders are: $(nux.cfg.get.path templates)"
|
||||
for _dir in $(nux.cfg.get.path templates) ; do
|
||||
find $_dir -maxdepth 1 -iname "*.nuxfs"
|
||||
done | xargs -n1 basename --suffix $SUFFIX | sort | uniq
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue