From fc1b5bbc87cdd69b99e34599dc46109b5ad151ff Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Mon, 28 Jan 2019 06:22:49 +0100 Subject: [PATCH] Added taskie configuration & other stuff. Signed-off-by: Tony Tkacik --- bin/mvln | 49 ++++++ bin/nudsl | 43 +++++ bin/nux-env | 11 +- bin/nuxr.nuxsh | 153 ++++++++++++++++++ bin/tdm-media | 8 +- config/nuxfs/templates/gnome-material.nuxfs | 10 ++ config/nuxfs/templates/nux-app.nuxfs | 8 + .../nuxfs/templates/tonydamage-public.nuxfs | 21 +++ config/taskie/config.yaml | 6 + inc/nudsl.inc.sh | 141 ++++++++++++++++ inc/nudsl/nuxdsl.inc.sh | 68 ++++++++ inc/nudsl/nuxfs.inc.sh | 10 ++ inc/nudsl/yanglike.inc.sh | 69 ++++++++ inc/nux.xml.inc.sh | 124 ++++++++++++++ inc/nux/check.inc.sh | 3 +- inc/nux/nuxsh.inc.sh | 9 +- inc/nuxr.nuxsh.sh | 2 +- inc/nweb.inc.sh | 0 machine/bootstrap/x64-nuxenv.sh | 16 ++ 19 files changed, 744 insertions(+), 7 deletions(-) create mode 100755 bin/mvln create mode 100755 bin/nudsl create mode 100644 bin/nuxr.nuxsh create mode 100644 config/nuxfs/templates/gnome-material.nuxfs create mode 100644 config/nuxfs/templates/nux-app.nuxfs create mode 100644 config/nuxfs/templates/tonydamage-public.nuxfs create mode 100644 config/taskie/config.yaml create mode 100644 inc/nudsl.inc.sh create mode 100644 inc/nudsl/nuxdsl.inc.sh create mode 100644 inc/nudsl/nuxfs.inc.sh create mode 100644 inc/nudsl/yanglike.inc.sh create mode 100644 inc/nux.xml.inc.sh create mode 100644 inc/nweb.inc.sh create mode 100755 machine/bootstrap/x64-nuxenv.sh diff --git a/bin/mvln b/bin/mvln new file mode 100755 index 0000000..50df9ac --- /dev/null +++ b/bin/mvln @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +declare -a sources + +target=$1; shift; + +i=0 +while [ "$#" -gt 0 ]; do + sources[$i]="$1"; + shift; + let i=i+1; +done + +function move-and-link-to-folder { + local s="$1"; shift; + local target="$1"; shift; + local name=$(basename "$s"); + local sdir=$(dirname "$s"); + local target_path=$(realpath -Ls --relative-to="$sdir" "$target/$name" ) + mv "$s" "$target" + ln -sf "$target_path" "$s" +} + +function move-and-link { + local s="$1"; shift; + local target="$1"; shift; + local sdir=$(dirname "$s"); + local target_path=$(realpath -Ls --relative-to="$sdir" "$target" ) + mv "$s" "$target" + ln -sf "$target_path" "$s" +} + +if [ "$i" -gt 1 ]; then + if [ -d "$target" ]; then + for s in "${sources[@]}"; do + move-and-link-to-folder "$s" "$target" + done + else + echo "Target $target is not directory." + exit 1 + fi +else + s="${sources[0]}" + if [ -d "$target" ]; then + move-and-link-to-folder "$s" "$target" + else + move-and-link "$s" "$target" + fi +fi diff --git a/bin/nudsl b/bin/nudsl new file mode 100755 index 0000000..1941b7d --- /dev/null +++ b/bin/nudsl @@ -0,0 +1,43 @@ +#!/usr/bin/env nux-runner + +nux.use nudsl + +## highlight:: + +task.highlight() { + nux.use nux/nuxsh + nux.dsl.process highlight nux.nuxsh.language.def "$2" +} + +task.language.show() { + nudsl.language.cache lang.yanglike.def +} + +task.plan() { + nuxr.run.subtask "$@" +} + +task.plan.compile() { + nux.use nudsl/$1 + nudsl.plan lang.$1.def "$2" +} + +task.plan.preview() { + nux.use nux/nuxsh + nux.dsl.plan nux.nuxsh.language "$2" + plan="$(nudsl.plan.file "$1" "$2")" + if [ -e "$plan" ]; then + if [ -n "$(which pygmentize)" ]; then + pygmentize -l bash "$plan"; + else + cat "$plan"; + fi + else + echo "Plan not available" + fi +} + +task.run() { + echo "$@" + nudsl.process "lang.yanglike.def" "$2" +} diff --git a/bin/nux-env b/bin/nux-env index 1553eb4..e43df2a 100755 --- a/bin/nux-env +++ b/bin/nux-env @@ -31,7 +31,7 @@ ## fixmes:: ## List all fixmes for nux-env function :fixmes { - fgrep -n FIXME "$NUX_INC_DIR/..bin/"* + fgrep -n FIXME "$NUX_INC_DIR/..bin/"* find "$NUX_INC_DIR" -iname "*.sh" | xargs fgrep -n FIXME } @@ -39,6 +39,13 @@ ## Displays help for specified nuxs-env library. ## function :help.library name { - nux.help.comment $NUX_INC_DIR/$name.inc.sh + nux.log debug "Library" + if [ -e "$NUX_INC_DIR/$name.inc.sh" ] { + nux.help.comment $NUX_INC_DIR/$name.inc.sh + elif [ -e "$NUX_INC_DIR/$name.nuxsh.sh" ]; then + nux.help.comment $NUX_INC_DIR/$name.nuxsh.sh + else + nux.fatal "Library not found" + } } } diff --git a/bin/nuxr.nuxsh b/bin/nuxr.nuxsh new file mode 100644 index 0000000..ad1150e --- /dev/null +++ b/bin/nuxr.nuxsh @@ -0,0 +1,153 @@ +#!/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/tdm-media b/bin/tdm-media index 47797a7..c2c132e 100755 --- a/bin/tdm-media +++ b/bin/tdm-media @@ -26,7 +26,13 @@ function task.downscale { mkdir -p $TARGET; for image in "$@"; do let "i=i+1" - target_file=$TARGET/$(basename $image) + name=$(basename $image); + target_file=$TARGET/$name; + if [ -n "$PRESERVE" ]; then + target_dir="${TARGET}/$(dirname "$image")"; + mkdir -p "$target_dir"; + target_file="${target_dir}/$name"; + fi echo "Image: $i/$count Downsampling $image -> $target_file" convert $image \ -filter Lanczos -sampling-factor 1x1 \ diff --git a/config/nuxfs/templates/gnome-material.nuxfs b/config/nuxfs/templates/gnome-material.nuxfs new file mode 100644 index 0000000..ff2206d --- /dev/null +++ b/config/nuxfs/templates/gnome-material.nuxfs @@ -0,0 +1,10 @@ +dir ".ui" + git "Flat-Remix" "https://github.com/daniruiz/Flat-Remix" + git "Flat-Remix-GNOME-theme" "https://github.com/daniruiz/Flat-Remix-GNOME-theme" +enddir +dir ".themes" + link "Flat Remix" "../.ui/Flat-Remix-GNOME-theme/Flat Remix/" +enddir +dir ".icons" + link "Flat Remix" "../.ui/Flat-Remix/Flat Remix/" +enddir diff --git a/config/nuxfs/templates/nux-app.nuxfs b/config/nuxfs/templates/nux-app.nuxfs new file mode 100644 index 0000000..1b62694 --- /dev/null +++ b/config/nuxfs/templates/nux-app.nuxfs @@ -0,0 +1,8 @@ +name Nux Application Template +dir bin + +enddir bin + +dir inc + +enddir diff --git a/config/nuxfs/templates/tonydamage-public.nuxfs b/config/nuxfs/templates/tonydamage-public.nuxfs new file mode 100644 index 0000000..6af5167 --- /dev/null +++ b/config/nuxfs/templates/tonydamage-public.nuxfs @@ -0,0 +1,21 @@ +dir bin + link mvn ../apps/maven/bin/mvn + link eclipse ../apps/eclipse/eclipse +enddir + +dir .repos + dir m2; enddir; + dir p2; enddir; + dir npm; enddir; +enddir + + +git "nux-env" "ssh://git@github.com/tonydamage/nux-env" +link .bashrc nux-env/bashrc + +link .m2 .repos/m2 +link .p2 .repos/p2 +link .npm .repos/npm + +should-not-exists "*.tmp" +should-not-exists "*.stl" diff --git a/config/taskie/config.yaml b/config/taskie/config.yaml new file mode 100644 index 0000000..75bef10 --- /dev/null +++ b/config/taskie/config.yaml @@ -0,0 +1,6 @@ +backends: + preference: gogs github +colors: + labels: + bug: red + enhancement: blue diff --git a/inc/nudsl.inc.sh b/inc/nudsl.inc.sh new file mode 100644 index 0000000..8d2dec1 --- /dev/null +++ b/inc/nudsl.inc.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash + +## nulang - NUX Custom DSL Support Library +## +## # Language Definition +## +## Language is defined in terms of BASH REGEX matches and functions that process +## or execute particular match. + +NUDSL_CACHE_SUFFIX=".nudsl.sh" + +nudsl.eval() { + $nudsl_eval "$@" +} + +nudsl.dsl.func() { + .process.highlight() { + echo "$line"; + } + .match._unmatched.highlight() { + echo "${_gen_highlight_unmatched}$line${nc_end}" + } + + .gen.parser._unmatched.process() { + nux.exec.or .match._unmatched.$action .process.$action + } + + .highlight() { + nudsl.eval _gen_highlight_$1='$nc_'$2 + } + .match() { + local type=$1; + local pattern=$2; + shift; shift; + i=0; + local parse_body=""; + nudsl.eval _gen_parser_types='"$_gen_parser_types '$type'"' + nudsl.eval _gen_parser_pattern_$type="'"$pattern"'" + nudsl.eval """.gen.parser.$type.process() { + $( + for group in "$@"; do + let i=$i+1; + if [ "$group" != "-" ]; then + echo local ${group}='${BASH_REMATCH['$i']}' + fi + done + ) + nux.exec.or .match.$type.\$action .process.\$action + } + """ + + nudsl.eval """.match.$type.highlight() { + $( + for group in "$@"; do + let i=$i+1; + if [ "$group" != "-" ]; then + echo ' echo -n "${_gen_highlight_'$group'}$'$group'${nc_end}"' + fi + done + ) + echo; + } + """ + + } +} + +nudsl_eval=eval + +nudsl.process() { + local action=$1; + local language=$2; + local file=$3; + ( + nudsl.dsl.func + $language + cat "$file" | nudsl.process0 $action) +} + +nudsl.exec() { + language="$1"; + file="$2"; + cached="$file${NUDSL_CACHE_SUFFIX}"; + if nudsl.plan "$language" "$file"; then + source "$cached"; + fi +} + +nudsl.plan.file() { + local language="$1" + local file="$2"; + echo "$file${NUDSL_CACHE_SUFFIX}"; +} + +nudsl.plan() { + local language="$1"; + local file="$2"; + + cached="$(nudsl.plan.file $language $file)"; + if [ "$file" -ot "$cached" -a -e "$nudsl_refresh" ]; then + nux.log debug nudsl: $file: No need to recompile. + return; + fi + + nux.log debug Needs regeneration, creating new version. + + local dirname=$(dirname "$file") + local execution_plan=$(mktemp "$dirname/.nudsl.XXXX") + if (nudsl.process plan "$language" "$file" > "$execution_plan") ; then + mv -f "$execution_plan" "$cached"; + else + echo "Plan could not be generated. See errors." + rm "$execution_plan" + return -1; + fi +} + +nudsl.process.fail() { + process_failed=true + echo "$linenum:$@" >&2 +} + +nudsl.process0() { + local _gen_parser_pattern__unmatched='(.*)'; + local patterns="$_gen_parser_types _unmatched"; + local linenum=0; + while IFS= read -r line ; + do + let linenum=$linenum+1 + for t in $patterns; do + local pattern=_gen_parser_pattern_$t + if [[ "$line" =~ ${!pattern} ]]; then + .gen.parser.$t.process + break; + fi + done + if [ -n "$process_failed" ]; then + return -1; + fi + done; +} diff --git a/inc/nudsl/nuxdsl.inc.sh b/inc/nudsl/nuxdsl.inc.sh new file mode 100644 index 0000000..a9134b5 --- /dev/null +++ b/inc/nudsl/nuxdsl.inc.sh @@ -0,0 +1,68 @@ +nux.use nudsl/yanglike + + +lang.nuxdsl.strict.def() { + lang.yanglike.def + + .keyword.plan() { + nudsl.process.fail "undefined keyword: $keyword"; + } + .block.start.plan() { + nudsl.process.fail "undefined block: $keyword"; + } + .block.end.plan() { + echo "${indent}end${keyword}"; + } + + .match._unmatched.plan() { + nudsl.process.fail "invalid syntax: $line"; + } +} + +lang.nuxdsl.def() { + lang.nuxdsl.strict.def + + .keyword.plan() { + echo "$indent$keyword $args"; + } + .block.start.plan() { + .keyword.plan + } + .block.end.plan() { + echo "${indent}end${keyword}"; + } + + .match._unmatched.plan() { + echo "$line"; + } + +} + +.default.plan() { + echo "$indent$keyword $args"; +} +.blockend.plan() { + echo "${indent}end${keyword}"; +} + +.block() { + eval """ + .block.$1.start.plan() { + .default.plan + } + .block.$1.end.plan() { + .blockend.plan + } + .keyword.$1.plan() { + .default.plan + } +""" +} + +.keyword() { + eval """ + .keyword.$1.plan() { + .default.plan + } +""" +} diff --git a/inc/nudsl/nuxfs.inc.sh b/inc/nudsl/nuxfs.inc.sh new file mode 100644 index 0000000..ab73af5 --- /dev/null +++ b/inc/nudsl/nuxfs.inc.sh @@ -0,0 +1,10 @@ +nux.use nudsl/nuxdsl + +lang.nuxfs.def() { + lang.nuxdsl.strict.def +} + +.block dir +.keyword link +.keyword git +.keyword should-not-exists diff --git a/inc/nudsl/yanglike.inc.sh b/inc/nudsl/yanglike.inc.sh new file mode 100644 index 0000000..ec7fd89 --- /dev/null +++ b/inc/nudsl/yanglike.inc.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +nux.use nudsl/blocktrac + +## # nudsl/yanglike - Basic skeleton for YANG-like languages + +## +## yanglike is barebones support for development of YANG-like languages +## with two main concepts: blocks and simple statements. +## +## The syntax of language is following: +## +## *statement* = <*block*> | <*simple*> +## *block* = <*keyword*> [*arg*]* **{** +## [*statement*]* +## *}* +## *simple* = <*keyword*> [*arg*]*; +## *arg* = <*uarg*> | <*darg*> | <*sarg*> +## *uarg* - unquoted argument +## *sarg* - single quoted argument +## *darg* - double quoted argument +## +## Language support is basic with following restrictions: +## - one statement per line + + +## +## lang.yanglike.def :: +## Definition of *yanglike* language +## +lang.yanglike.def() { + local comment='(( *)(#.*))?' + local whitespace="([ ]*)" + local uarg="([^ #\{\}\"'\"'\"';]+)"; + local sarg="('\"'\"'[^'\"'\"']+'\"'\"')"; + local darg='("[^"]*")'; + local args="((($uarg|$darg|$sarg) *)*)"; + .match.line() { + local type="$1"; + local match="^( *)$2$comment$"; + shift;shift; + .match "$type" "$match" indent "$@" - indent_comment comment; + } + + .match.line comment '' + .match.line block_end '(\})' \ + syntax + .match.line block_start "([^ ]+)( +)$args( *)(\{)" \ + keyword indent2 args - - - - - indent3 syntax + .match.line keyword "([^ ]+)( +)$args?( *)(;)"\ + keyword indent2 args - - - - - indent3 syntax + + + .highlight keyword green + .highlight syntax blue + .highlight args yellow + .highlight unmatched bg_red +} + + +.match.comment.plan() { + nux.exec.optional .comment.plan +} + + +.match.keyword.plan() { + #nux.log trace "Executing plan for ''$keyword'" + nux.exec.or .keyword.$keyword.plan .keyword.plan +} diff --git a/inc/nux.xml.inc.sh b/inc/nux.xml.inc.sh new file mode 100644 index 0000000..925a7a1 --- /dev/null +++ b/inc/nux.xml.inc.sh @@ -0,0 +1,124 @@ +## #nux.json NUX Script JSON Helper library +## +## #Public functions + +## nux.xml.start +## Starts operation on new JSON. Resets write operations stack and JSON +## source file to empty (useful for creating JSON from scratch.) +function nux.xml.start { + nux_xml_opstack=""; + nux_xml_source=""; + nux_xml_root=""; +} + +## nux.xml.open +## Opens JSON File for reading and writing using *nux.xml.open* and +## *nux.xml.write* commands. +## +## In order to work with empty JSON use *-n* as *file*. This allows +## for creating new JSON from scratch. +## +## NOTE: Open does not reset operation stack. To reset operation stack +## and opened file use *nux.xml.start* +function nux.xml.open { + local file="$1" + if [ -f "$file" ]; then + nux_xml_source="$file" + fi +} + +## nux.xml.read +## Reads *path* from currently opened JSON file. +## NOTE: Read does not see changes performed by *nux.xml.write* unless +## these changes were flushed using *nux.xml.flush*. +function nux.xml.read { + local path=".$1"; + xmlstarlet -r "$path" "$nux_xml_source"; +} + +## nux.xml.write +## Adds write operation to action stack. Writes are not performed +## immediately, but rather when *nux.xml.flush* is invoked. +## This allows for batching of operations or opting out of actually +## modifying file. +function nux.xml.write { + local path="/${1//\./\/}"; + if [ -z "$nux_xml_root" ] ; then + nux_xml_root=$(cut -d "/" -f2 <<< "$path") + nux.log debug "Root is $nux_xml_root"; + fi + nux.log debug "Path to write is: $path"; + local value="$2"; + nux_xml_opstack="${nux_xml_opstack} -a $path -t elem -v \"$value\"" +} + +function nux.xml.write.raw { + local path=".$1"; + local value="$2"; + nux_xml_opstack="${nux_xml_opstack} | $path |= $value" +} + +## nux.xml.flush [] +## Flushes any write operations to specified *target* file. +## If *target* is not specified JSON is outputted to *STDIN*. +## +## NOTE: Flush does not reset operation stack. To reset +## operation stack and opened file use *nux.xml.start* +## +function nux.xml.flush { + local target="$1" + if [ -z "$nux_xml_source" ] ; then + nux_xml_source=$(mktemp); + echo "<$nux_xml_root>"; + fi + nux.log debug Opstack is: $nux_xml_opstack + if [ -n "$target" ]; then + local write_target="$target"; + if [ "$nux_xml_source" == "$target" ]; then + write_target=$(mktemp "$(dirname "$target")/tempXXXXXX.json") + fi + xmlstarlet ed $nux_xml_opstack "$nux_xml_source" > "$write_target" + if [ "$nux_xml_source" == "$target" ]; then + mv -f "$write_target" "$target" + fi + else + xmlstarlet ed $nux_xml_opstack "$nux_xml_source" + fi +} + +## nux.xml.shorthands +## Exposes shorthands for writing and reading from JSON file. +## *njw* - nux.xml.write +## *njr* - nux.xml.read +## +function nux.xml.shorthands { + function nxw { + nux.xml.write "$@" + } + function nxr { + nux.xml.read "$@" + } +} + +## # Usage Notes +## +## ## Operation stack and flush +## +## As mentioned in documentation for *nux.xml.flush* write stack +## is not removed, but rather kept alone, separatly from reference +## to open file. This allows for having modification template +## which could be executed on multiple files. +## +## The following example adds meta.author and meta.email +## to every JSON in directory. +## +## *nux.xml.start* +## *nux.xml.write* meta.author "Tony Tkacik" +## *nux.xml.write* meta.email "example@example.com" +## *for* f *in* "*.xml"; +## *do* +## *nux.xml.open* "$f" +## *nux.xml.flush* "$f" +## *done*; +## +## diff --git a/inc/nux/check.inc.sh b/inc/nux/check.inc.sh index 6432309..026c5a3 100644 --- a/inc/nux/check.inc.sh +++ b/inc/nux/check.inc.sh @@ -2,8 +2,9 @@ ## function nux.check.function { nux.log trace "Checking if $1 is function." - declare -f "$1" &>/dev/null && return 0 + test "$(type -t "$1")" = "function" && return 0 return 1 + } function nux.check.nuxenv.file { diff --git a/inc/nux/nuxsh.inc.sh b/inc/nux/nuxsh.inc.sh index bc86807..faf35bd 100644 --- a/inc/nux/nuxsh.inc.sh +++ b/inc/nux/nuxsh.inc.sh @@ -10,7 +10,7 @@ nux.nuxsh.language.def() { local args="((($uarg|$darg|$sarg) *)*)"; - local prefixed_id="([^ :]*:)?($identifier)" + local prefixed_id="([^= :]*:)?($identifier)" .match.line() { local type="$1"; @@ -107,7 +107,12 @@ nux.nuxsh.language.def() { .identifier() { if [ -n "$prefix" ]; then local var=_import_prefix_${prefix%:} - local prepend=${!var}; + local prepend; + if [ -n "$var" ]; then + prepend=${!var}; + else + prepend=$_namespace; + fi if [ -z "$prepend" ] ; then nudsl.process.fail "undefined prefix: $prefix"; fi diff --git a/inc/nuxr.nuxsh.sh b/inc/nuxr.nuxsh.sh index 6c7da37..a388c3a 100644 --- a/inc/nuxr.nuxsh.sh +++ b/inc/nuxr.nuxsh.sh @@ -9,6 +9,7 @@ nux.use nuxr/repl function :run TASK { if check:function task.$TASK { 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." @@ -67,7 +68,6 @@ nux.use nuxr/repl topic="$@" topic_dot=$(tr " " "." <<< $topic) nux.log trace "Displaying topic for: '$topic' '$topic_dot'" - if check:function "task.help.$topic_dot" { shift; task.help.$topic "$@"; diff --git a/inc/nweb.inc.sh b/inc/nweb.inc.sh new file mode 100644 index 0000000..e69de29 diff --git a/machine/bootstrap/x64-nuxenv.sh b/machine/bootstrap/x64-nuxenv.sh new file mode 100755 index 0000000..dedfe5f --- /dev/null +++ b/machine/bootstrap/x64-nuxenv.sh @@ -0,0 +1,16 @@ +#!/bin/bash +function .not_present() { + if which "$1" &> /dev/null; then + return 1 + fi + return 0; +} + +if .not_present yaml; then + wget https://github.com/mikefarah/yaml/releases/download/1.11/yaml_linux_amd64 -O ~/bin/yaml + chmod +x ~/bin/yaml +fi + +if .not_present jq; then + apt install jq +fi