=====================================================================

--- Changes ------------------------------

- system/config/symlink )
   now copies the existing config from the current system if
   the "source" config does not exist (init from local)

- allowed implementation of group-custom scwrypt listing function
   GET_AVAILABLE_SCWRYPTS__<group-name>

--- Bug Fixes ----------------------------

- fixed a bug where custom runstring operators were ignored
This commit is contained in:
Wryn (yage) Wagner 2023-07-20 15:11:07 -06:00
parent 620d07f1a8
commit e2c6007a65
4 changed files with 31 additions and 13 deletions

2
run
View File

@ -316,8 +316,6 @@ __GET_LOGFILE() {
|| [[ $SCWRYPT_NAME =~ interactive ]] \
&& return 0
echo 'gets a logfile' >&2
echo "$SCWRYPTS_LOG_PATH/$(echo $GROUP/$TYPE/$NAME | sed 's/^\.\///; s/\//\%/g').log"
}

View File

@ -20,14 +20,14 @@ SCWRYPTS__GET_AVAILABLE_SCWRYPTS() {
GROUP_TYPE=$(eval echo '$SCWRYPTS_TYPE__'$GROUP)
[ $GROUP_TYPE ] && MINDEPTH=1 && GROUP_TYPE="$GROUP_TYPE\\/" || MINDEPTH=2
{
cd "$GROUP_PATH"
find . -mindepth $MINDEPTH -type f -executable \
| grep -v '\.git' \
| grep -v 'node_modules' \
| sed "s/^\\.\\///; s/\\.[^.]*$//; s/^/$GROUP_TYPE/" \
| sed "s|\\([^/]*\\)/\(.*\)$|$(printf $__COLOR_RESET)\\2^$(printf $TYPE_COLOR)\\1^$(printf $GROUP_COLOR)$GROUP$(printf $__COLOR_RESET)|" \
command -v SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__$GROUP >/dev/null 2>&1 \
&& LOOKUP=SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__$GROUP \
|| LOOKUP=SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__scwrypts \
;
{
$LOOKUP \
| sed "s|\\([^/]*\\)/\(.*\)$|$(printf $__COLOR_RESET)\\2^$(printf $TYPE_COLOR)\\1^$(printf $GROUP_COLOR)$GROUP$(printf $__COLOR_RESET)|" \
} &
LOOKUP_PIDS+=($!)
done
@ -46,6 +46,17 @@ SCWRYPTS__SEPARATE_SCWRYPT_SELECTION() {
done
}
SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__scwrypts() {
# implementation should output lines of the following format:
# "${SCWRYPT_TYPE}/${SCWRYPT_NAME}"
cd "$GROUP_PATH"
find . -mindepth $MINDEPTH -type f -executable \
| grep -v '\.git' \
| grep -v 'node_modules' \
| sed "s/^\\.\\///; s/\\.[^.]*$//; s/^/$GROUP_TYPE/" \
;
}
SCWRYPTS__GET_RUNSTRING() {
local GROUP_PATH=$(eval echo '$SCWRYPTS_ROOT__'$SCWRYPT_GROUP)
local RUNSTRING
@ -60,7 +71,7 @@ SCWRYPTS__GET_RUNSTRING() {
return 1
}
typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} >/dev/null 2>&1 && {
[ ! $RUNSTRING ] && typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} >/dev/null 2>&1 && {
RUNSTRING=$(SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE})
[ ! $RUNSTRING ] && {
ERROR "SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} error"
@ -68,7 +79,7 @@ SCWRYPTS__GET_RUNSTRING() {
}
}
typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} >/dev/null 2>&1 && {
[ ! $RUNSTRING ] && typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} >/dev/null 2>&1 && {
RUNSTRING=$(SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE})
[ ! $RUNSTRING ] && {
ERROR "SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} error"

View File

@ -21,6 +21,7 @@ for ENV_FILE in ${ENV_FILES[@]}
do
[ ! -f "$ENV_FILE" ] && {
STATUS "Creating '$ENV_FILE'..." \
&& mkdir -p "$(dirname "$ENV_FILE")" \
&& touch "$ENV_FILE" \
&& ((CREATED+=1)) \
&& SUCCESS "created '$ENV_NAME'" \

View File

@ -18,10 +18,18 @@ SETUP_SYMLINK() {
[ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
local SOURCE_CONFIG="$1"
[ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && FAIL 2 "no such file or directory '$SOURCE_CONFIG'"
local TARGET_CONFIG="$HOME/.config/$2"
[ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && [ -f "$TARGET_CONFIG" ] && {
INFO 'SOURCE_CONFIG is not tracked; copying from TARGET_CONFIG'
mkdir -p "$(dirname "$SOURCE_CONFIG")"
cp "$TARGET_CONFIG" "$SOURCE_CONFIG"
}
[ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && {
WARNING "no such file or directory '$SOURCE_CONFIG'"
return 0
}
[ ! -d $(dirname "$TARGET_CONFIG") ] && mkdir -p $(dirname "$TARGET_CONFIG")
[[ $SAFE_SYMLINKS -eq 1 ]] \