diff --git a/bin/foldy b/bin/foldy new file mode 100755 index 0000000..e19afb2 --- /dev/null +++ b/bin/foldy @@ -0,0 +1,35 @@ +#!/usr/bin/env nuxr-nuxsh +nux.use nux/fs + +CLOSEST=$(nux.fs.closest .foldy.nuxsh) + +## suffix:: +## Adds random UUID suffix to file names if file does not have UUID in name already. +@command list { + nux.fs.info "Listing foldy files in $CLOSEST" +} + +@command help.additional { + echo "Tasks defined in ${NC_White}$CLOSEST${NC_No}" + echo "Custom Help" + nux.help.comment "$CLOSEST" + +} + +nuxr.run.additional { + if [[ -f "$CLOSEST" ]]; then + nux.log debug Loading sources fron "$CLOSEST" + + nux.nuxsh.use "$CLOSEST" + fi + + if nux.check.function task.$TASK; then + nux.log debug "Running task: $TASK"; + nux.log debug "Working dir: $(pwd)" + task.$TASK "$@" # Runs task + else + echo "$NUX_SCRIPTNAME: Unrecognized task '$TASK' not available." + echo "Try '$NUX_SCRIPTNAME help' for more information." + return -1 + fi +} \ No newline at end of file diff --git a/inc/nuxr.nuxsh.sh b/inc/nuxr.nuxsh.sh index 5d493e8..85f6434 100644 --- a/inc/nuxr.nuxsh.sh +++ b/inc/nuxr.nuxsh.sh @@ -8,15 +8,18 @@ nux.use nux/help @namespace nuxr. { function :run TASK { # FIXME: Add default task - if check:function task.$TASK { + if nux.check.function task.$TASK; then nux.log debug "Running task: $TASK"; nux.log debug "Working dir: $(pwd)" task.$TASK "$@" # Runs task + elif nux.check.function nuxr.run.additional; then + nux.log debug "Running additional task: $TASK"; + nuxr.run.additional "$TASK" "$@" else echo "$NUX_SCRIPTNAME: Unrecognized task '$TASK' not available." echo "Try '$NUX_SCRIPTNAME help' for more information." return -1 - } + fi } function :run.subtask SUBTASK {