diff --git a/bin/nuxfs b/bin/nuxfs index 4eb23e3..13509da 100755 --- a/bin/nuxfs +++ b/bin/nuxfs @@ -261,7 +261,7 @@ function task.capture { nuxr.repl.expose cd pwd ls find nuxr.repl.prompt() { - echo "${nc_green}$NUX_APPNAME${nc_end}:${nc_blue}$(pwd)${nc_end}> " + echo "${nc_green}$NUX_SCRIPTNAME${nc_end}:${nc_blue}$(pwd)${nc_end}> " } function nuxfs.template.list { diff --git a/bin/nuxr-nuxsh b/bin/nuxr-nuxsh index b1beaea..ebf5681 100755 --- a/bin/nuxr-nuxsh +++ b/bin/nuxr-nuxsh @@ -132,6 +132,9 @@ if [ -n "$NUX_SCRIPT" ]; then NUX_SCRIPTNAME=$(basename "$NUX_SCRIPT") + NUX_APP_NAME="${NUX_APP_NAME:=$NUXR_APP_NAME}" + NUX_APP_DIR="${NUX_APP_DIR:=$NUXR_APP_DIR}" + nux.log trace "NUX_SCRIPT env: " $(set | grep NUX_SCRIPT) if [ -z "$NUX_NO_INCLUDE" ] then @@ -143,6 +146,9 @@ if [ -n "$NUX_SCRIPT" ]; then nux.nuxsh.use "$NUX_SCRIPT" "/tmp/$compilefile.nuxr.nuxsh"; NUX_NO_INCLUDE="no-include" fi + + + nuxr.main "$@" else diff --git a/bin/nuxr.nuxsh b/bin/nuxr.nuxsh deleted file mode 100644 index ad1150e..0000000 --- a/bin/nuxr.nuxsh +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env bash - -### -### *nuxr-nuxsh* is wrapped bash interpreter for *nux-env* enhanced bash scripts -### and provides out of the box support for command-style scripts (similar in -### usage such as apt, git) with following features out of the box: -### -### task selection:: -### Automaticly selects correct tasks, displays help if -### task does not exists. -### logging:: -### Using *nux.log* function and changing output using -### *debug*, *trace* prefixes -### help display:: -### Automated help display when no arguments are provided. -### Uses source comments as source for help. -### -### -### # Writing nux-runner scripts -### -### *nux-runner* scripts are basicly bash scripts with some additional conventions. -### -### -### -### -### -### 1. Shebang:: -### Shebang (*#!*) at the start of file is *#!/usr/bin/env nuxr-nuxsh* -### 2. Tasks:: -### Script usually does only defines functions in form task {taskname} -### where taskname -### ## Defining a task -### -### -### -### - - -readonly NUX_RUNNER_BIN_DIR=$(dirname $(realpath ${BASH_SOURCE[0]})) -source $NUX_RUNNER_BIN_DIR/../inc/nux.inc.sh -readonly NUX_RUNNER=$NUX_RUNNER_BIN_DIR/nuxr-nuxsh; - -nux.use nuxr -nux.use nux.cfg - -## -## Additional commands provided by *nux-runner*: -### *nux-runner* automaticly provides following tasks to any script it executes: - -## - - - -## debug:: [] -## Runs specified task with debug messages enabled. -task.debug() { - nux.log.level debug - nuxr.run "$@" -} - -## trace:: [] -## Runs specified task with debug & trace enabled. -task.trace() { - nux.log.level trace - nuxr.run "$@" -} - -## help:: [command] -## Display help for command or topic if specified. Otherwise displays -## documentation. -task.help() { - nuxr.task.help "$@" -} - -## config:: [type] name [value] -## Reads or writes application specific configuration option. -### -### There are 3 *types* of configuration: -### dist:: -### Distribution provided configuration. Read-only configuration. -### global:: -### Global (user-specific) provided configuration. This configuration is -### usually stored in *~/.config/{app-name}/config.yml* -### local:: -### Local configuration. -### -### The resulting application configuration is merger of these three (if available) -### with following preference (most-specific one): -### local, global, dist -### -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.() { - task.help -} - - -## interactive:: -## Executes interactive application shell. -task.interactive() { - nuxr.task.interactive "$@" -} -### -### - -if [ "$NUX_RUNNER" = "$(realpath "$0")" ] -then - NUX_SCRIPT=$1; - shift; -else - NUX_SCRIPT=$0; - NUX_NO_INCLUDE="no include"; -fi - -if [ -n "$NUX_SCRIPT" ]; then - # Determines script - NUX_SCRIPT_DIR=$(dirname "$NUX_SCRIPT") - NUXR_APP_BIN=$(realpath "$NUX_SCRIPT") - NUXR_APP_BIN_DIR=$(dirname "$NUXR_APP_BIN") - NUXR_APP_DIR=$(dirname "$NUXR_APP_BIN_DIR") - NUXR_APP_NAME=$(basename "$NUX_SCRIPT") - - NUX_SCRIPTNAME=$(basename "$NUX_SCRIPT") - - nux.log trace "NUX_SCRIPT env: " $(set | grep NUX_SCRIPT) - if [ -z "$NUX_NO_INCLUDE" ] - then - nux.log debug "Including script: $NUX_SCRIPT" - nux.log trace "NUX_SCRIPT env: " $(set | grep NUX_SCRIPT) - - local tmpfile=$(realpath nux-env | md5sum | cut -d" " -f1) - nux.nuxsh.use "$NUX_SCRIPT" "/tmp/nuxsh/$tmpfile"; # Includes script // FIXME: Add nuxsh support - - NUX_NO_INCLUDE="no-include" - fi - nuxr.main "$@" -else - - echo Usage: nux-runner [script] [task] [options] - echo - grep "^\#\#" "$NUX_RUNNER" | sed -re "s/^#+ ?(.*)/\1/gi" | nux.help.shelldoc - echo -fi diff --git a/bin/taskie b/bin/taskie index 0afc1ef..bf8f41d 100755 --- a/bin/taskie +++ b/bin/taskie @@ -59,7 +59,7 @@ task.add() { nuxr.repl.expose cd pwd ls clear nuxr.repl.prompt() { - echo "${nc_green}$NUX_APPNAME${nc_end}:${nc_blue}$(pwd)${nc_end}> " + echo "${nc_green}$NUX_SCRIPTNAME${nc_end}:${nc_blue}$(pwd)${nc_end}> " } ## diff --git a/inc/nux.cfg.inc.sh b/inc/nux.cfg.inc.sh index 85b2f63..17beb54 100644 --- a/inc/nux.cfg.inc.sh +++ b/inc/nux.cfg.inc.sh @@ -87,14 +87,14 @@ function nux.cfg.write { ## by library for customization of path format. ## function nux.cfg.dir.global { - echo "$HOME/.config/$NUX_APPNAME" + echo "$HOME/.config/$NUX_APP_NAME" } ## nux.cfg.dir.dist:: ## Returns path of *dist* config directory. SHOULD be overriden ## by library for customization of path format. function nux.cfg.dir.dist { - echo "$NUX_ENV_DIR/config/$NUX_APPNAME" + echo "$NUX_APP_DIR/config/$NUX_APP_NAME" } ## nux.cfg.dir.local:: ## Returns path of *local* config directory. SHOULD be overriden diff --git a/inc/nuxr.nuxsh.sh b/inc/nuxr.nuxsh.sh index a388c3a..fb14f71 100644 --- a/inc/nuxr.nuxsh.sh +++ b/inc/nuxr.nuxsh.sh @@ -77,7 +77,7 @@ nux.use nuxr/repl else nuxr.task.help.comment "$NUX_SCRIPT" "$topic" \ || nuxr.task.help.comment "$NUX_RUNNER" "$topic" \ - || echo "Help topic $1 not found. Run '$NUX_APPNAME help' to see topics." + || echo "Help topic $1 not found. Run '$NUX_SCRIPTNAME help' to see topics." } } diff --git a/inc/nuxr/repl.nuxsh.sh b/inc/nuxr/repl.nuxsh.sh index dfd3f1d..dbe7089 100644 --- a/inc/nuxr/repl.nuxsh.sh +++ b/inc/nuxr/repl.nuxsh.sh @@ -22,7 +22,7 @@ } function :prompt { - echo "${nc_green}$NUX_APPNAME${nc_end}> " + echo "${nc_green}$NUX_SCRIPTNAME${nc_end}> " } }