1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00

Fixed config and checks

This commit is contained in:
Tony Tkáčik 2023-08-24 10:56:40 +02:00
parent 8c3dd50750
commit 13b07244fb
3 changed files with 14 additions and 3 deletions

View file

@ -78,7 +78,6 @@ function :read {
nux.fatal "Unknown config store $store". nux.fatal "Unknown config store $store".
;; ;;
esac esac
shift;
:write.direct "$(nux.cfg.file.$store)" "$@" :write.direct "$(nux.cfg.file.$store)" "$@"
} }
@ -146,7 +145,7 @@ function :read {
mkdir -p "$(dirname "$file")"; mkdir -p "$(dirname "$file")";
touch "$file"; touch "$file";
fi fi
shift; nux.log debug "Args $@"
yaml w "$file" "$@" -i yaml w "$file" "$@" -i
} }

View file

@ -43,6 +43,14 @@ function nux.require {
} }
function nux.round {
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
};
function nux.calc {
echo "$@" | bc
}
## nux.use:: <library> ## nux.use:: <library>
function nux.use { function nux.use {
nux.log trace "nux.use: Including: $1" nux.log trace "nux.use: Including: $1"
@ -91,7 +99,7 @@ function nux.dirty.urlencode {
function nux.url.parse { function nux.url.parse {
format=${2:-"protocol:\2\nuser:\4\nhost:\5\nport:\7 \npath:\8"} format=${2:-"protocol:\2\nuser:\4\nhost:\5\nport:\7 \npath:\8"}
echo "$1" | sed \ echo "$1" | sed \
-re "s/(([^:\/]*):\/\/)?(([^@\/:]*)@)?([^:\/]+)(:([0-9]+))?(\/(.*))?/$format/g" -re "s/(([^:\/]*):\/\/)?(([^@\/:]*)@)?([^:\/]+)(:([0-9]+))?([:\/](.*))?\$/$format/g"
} }

View file

@ -30,3 +30,7 @@ function nux.check.exec {
function nux.check.file.exists { function nux.check.file.exists {
test -e "$1" -o -h "$1"; test -e "$1" -o -h "$1";
} }
function nux.check.file.symlink {
test -h "$1";
}