mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
72 lines
1.5 KiB
Bash
Executable file
72 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
###
|
|
### nux-runner is environment runner for nux-env enhanced bash scripts
|
|
### and provides out of the box support for task-style scripts
|
|
### (similar in usage such as apt, git).
|
|
###
|
|
|
|
|
|
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
|
|
|
|
##
|
|
## Commands provided by *nux-runner*:
|
|
|
|
|
|
## debug Runs specified task with debug messages enabled.
|
|
task.debug() {
|
|
nux.log.level debug
|
|
nux-runner.run "$@"
|
|
}
|
|
|
|
## trace Runs specified task with debug & trace enabled.
|
|
task.trace() {
|
|
nux.log.level trace
|
|
nux-runner.run "$@"
|
|
}
|
|
|
|
## help Display this help
|
|
task.help() {
|
|
echo Usage: $NC_Bold$NUX_SCRIPTNAME ${NC_No}${NC_White}\<command\>${NC_No} [\<options\>]
|
|
echo
|
|
grep -E "^\#\#\#( |$)" "$NUX_SCRIPT" | cut -d\# -f4- | cut -d" " -f2- | nux.help.shelldoc
|
|
echo
|
|
echo "Available Commands: "
|
|
nux.help.comment "$NUX_SCRIPT"
|
|
nux.help.comment "$NUX_RUNNER"
|
|
nux.exec.optional task.help.detailed
|
|
}
|
|
|
|
##
|
|
|
|
task.() {
|
|
task.help
|
|
}
|
|
|
|
if [ "$NUX_RUNNER" = "$(realpath "$0")" ]
|
|
then
|
|
readonly NUX_SCRIPT=$1;
|
|
shift;
|
|
else
|
|
readonly NUX_SCRIPT=$0;
|
|
readonly NUX_NO_INCLUDE="no include";
|
|
fi
|
|
|
|
if [ -n "$NUX_SCRIPT" ]; then
|
|
# Determines script
|
|
readonly NUX_SCRIPTNAME=$(basename $NUX_SCRIPT)
|
|
|
|
nux-runner.run "$@"
|
|
|
|
else
|
|
echo Usage: nux-runner [script] [task] [options]
|
|
echo
|
|
grep "^\#\#\# " "$NUX_RUNNER" | cut -d\# -f4-
|
|
echo
|
|
fi
|