each one for his own
parent
70f94540aa
commit
24583f03ee
|
@ -21,11 +21,31 @@ r3_completions() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${#COMP_WORDS[@]}" == "4" ]; then
|
if [ "${#COMP_WORDS[@]}" == "4" ]; then
|
||||||
COMPREPLY=($(compgen -W "extends normal system static system_base r3_base" "${COMP_WORDS[3]}"))
|
COMPREPLY=($(compgen -W "base extends component_base component_extends entity_base entity_extends r3_base runtime_base runtime_extends system_base system_extends static" "${COMP_WORDS[3]}"))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "component_extends" ] ; then
|
||||||
|
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-component/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
||||||
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "entity_extends" ] ; then
|
||||||
|
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-entity/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
||||||
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "runtime_extends" ] ; then
|
||||||
|
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-runtime/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
||||||
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "system_extends" ] ; then
|
||||||
|
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-system/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
||||||
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "extends" ] ; then
|
if [ "${#COMP_WORDS[@]}" == "5" ] && [ "${COMP_WORDS[3]}" == "extends" ] ; then
|
||||||
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/*.js "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-component/*.js "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-runtime/*.js "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/r3-entity/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
local classes=$(grep "^class" "${R3_INSTALL_PATH}"/r3-libs/r3-v2/src/r3/*.js | perl -pe "s/.*class\s*(\w.*?)\s.*/\1/" | perl -pe 's/\n/ /g')
|
||||||
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -34,11 +54,11 @@ r3_completions() {
|
||||||
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
COMPREPLY=($(compgen -W "${classes}" "${COMP_WORDS[4]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${#COMP_WORDS[@]}" == "5" && ( "${COMP_WORDS[3]}" == "normal" || "${COMP_WORDS[3]}" == "static") ]]; then
|
if [[ "${#COMP_WORDS[@]}" == "5" && ( "${COMP_WORDS[3]}" =~ ^.*base$ || "${COMP_WORDS[3]}" == "static") ]]; then
|
||||||
COMPREPLY=($(compgen -W "$(find "${R3_SRC_FOLDER}" -ls | grep drw | sed "s/.*src\/r3/./" | sed "s/$/\//" | sed "s/\/\//\//g" | perl -pe 's/\n/ /g')" "${COMP_WORDS[4]}"))
|
COMPREPLY=($(compgen -W "$(find "${R3_SRC_FOLDER}" -ls | grep drw | sed "s/.*src\/r3/./" | sed "s/$/\//" | sed "s/\/\//\//g" | perl -pe 's/\n/ /g')" "${COMP_WORDS[4]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${#COMP_WORDS[@]}" == "6" && ( "${COMP_WORDS[3]}" == "extends") ]]; then
|
if [[ "${#COMP_WORDS[@]}" == "6" && ( "${COMP_WORDS[3]}" =~ ^.*extends$ ) ]]; then
|
||||||
COMPREPLY=($(compgen -W "$(find "${R3_SRC_FOLDER}" -ls | grep drw | sed "s/.*src\/r3/./" | sed "s/$/\//" | sed "s/\/\//\//g" | perl -pe 's/\n/ /g')" "${COMP_WORDS[5]}"))
|
COMPREPLY=($(compgen -W "$(find "${R3_SRC_FOLDER}" -ls | grep drw | sed "s/.*src\/r3/./" | sed "s/$/\//" | sed "s/\/\//\//g" | perl -pe 's/\n/ /g')" "${COMP_WORDS[5]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0a88b49281d0ec5a28ebc9c68ec649ce5377a5be
|
Subproject commit d4c5e23f3a2294e267dfb656e13e8cd943502273
|
98
r3.sh
98
r3.sh
|
@ -92,65 +92,57 @@ fi
|
||||||
|
|
||||||
if [ "${TASK}" = 'create' ] || [ "${TASK}" = 'create-from-update-template' ];
|
if [ "${TASK}" = 'create' ] || [ "${TASK}" = 'create-from-update-template' ];
|
||||||
then
|
then
|
||||||
# echo "updating token.db"
|
|
||||||
# grep "GENERATED_.*_START" "${TEMPLATE_FOLDER}"*.template "${R3_FOLDER}"*.js "${R3_SYSTEM_FOLDER}"*.js -R | sed "s/^.*GENERATED_/GENERATED_/" | sed "s/_START$//" | sort --unique > "${TEMPLATE_FOLDER}"token.db
|
|
||||||
# grep "CUSTOM_.*_START" "${TEMPLATE_FOLDER}"*.template "${R3_FOLDER}"*.js "${R3_SYSTEM_FOLDER}"*.js -R | sed "s/^.*CUSTOM_/CUSTOM_/" | sed "s/_START$//" | sort --unique >> "${TEMPLATE_FOLDER}"token.db
|
|
||||||
|
|
||||||
CLASS_NAME=$ARG1
|
CLASS_NAME=$ARG1
|
||||||
FILE_NAME="r3$(echo "${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
|
||||||
TEMPLATE="${ARG2}.template"
|
TEMPLATE="${ARG2}.template"
|
||||||
|
FILE_NAME="r3$(echo "${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
||||||
|
|
||||||
|
SUBFOLDER='./'
|
||||||
|
if [ -n "${ARG4}" ];
|
||||||
|
then
|
||||||
|
SUBFOLDER="${ARG4}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SLASH_COUNT=$(echo "${SUBFOLDER}" | perl -lne 'END {print $c} map ++$c, /\//g')
|
||||||
|
|
||||||
|
INCLUDE_PATH='.'
|
||||||
|
|
||||||
|
for ((i=1; i < SLASH_COUNT; i++)) do
|
||||||
|
INCLUDE_PATH="../$INCLUDE_PATH"
|
||||||
|
done
|
||||||
|
|
||||||
EXTEND_CLASS=''
|
EXTEND_CLASS=''
|
||||||
EXTEND_CLASS_FILE_NAME=''
|
EXTEND_CLASS_FILE_NAME=''
|
||||||
SUBFOLDER='./'
|
if [[ "${ARG2}" =~ ^.*extends$ ]];
|
||||||
INCLUDE_PATH='.'
|
then
|
||||||
|
|
||||||
if [ "${ARG2}" = "extends" ]; then
|
|
||||||
EXTEND_CLASS="${ARG3}"
|
EXTEND_CLASS="${ARG3}"
|
||||||
EXTEND_CLASS_FILE_NAME="r3$(echo "${EXTEND_CLASS}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
EXTEND_CLASS_FILE_NAME="r3$(echo "${EXTEND_CLASS}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
||||||
|
|
||||||
SUBFOLDER="${ARG4}"
|
|
||||||
SLASH_COUNT=$(echo "${SUBFOLDER}" | perl -lne 'END {print $c} map ++$c, /\//g')
|
|
||||||
|
|
||||||
for ((i=1; i < SLASH_COUNT; i++)) do
|
|
||||||
INCLUDE_PATH="../$INCLUDE_PATH"
|
|
||||||
done
|
|
||||||
|
|
||||||
R3_FOLDER="${R3_FOLDER}${SUBFOLDER}"
|
|
||||||
|
|
||||||
echo "Creating class ${CLASS_NAME} based on template ${TEMPLATE} extending ${EXTEND_CLASS} and saving to ${R3_FOLDER}${FILE_NAME}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${ARG2}" = "normal" ] || [ "${ARG2}" = "static" ]; then
|
if [[ "${ARG2}" =~ ^.*base$ ]] ||
|
||||||
|
[ "${ARG2}" = "static" ];
|
||||||
|
then
|
||||||
|
|
||||||
|
if [ -n "${ARG3}" ];
|
||||||
|
then
|
||||||
SUBFOLDER="${ARG3}"
|
SUBFOLDER="${ARG3}"
|
||||||
|
fi
|
||||||
|
|
||||||
SLASH_COUNT=$(echo "${SUBFOLDER}" | perl -lne 'END {print $c} map ++$c, /\//g')
|
SLASH_COUNT=$(echo "${SUBFOLDER}" | perl -lne 'END {print $c} map ++$c, /\//g')
|
||||||
|
|
||||||
for ((i=1; i < SLASH_COUNT; i++)) do
|
for ((i=1; i < SLASH_COUNT; i++)) do
|
||||||
INCLUDE_PATH="../$INCLUDE_PATH"
|
INCLUDE_PATH="../$INCLUDE_PATH"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
R3_FOLDER="${R3_FOLDER}${SUBFOLDER}"
|
R3_FOLDER="${R3_FOLDER}${SUBFOLDER}"
|
||||||
|
|
||||||
|
if [ -z "${EXTEND_CLASS}" ];
|
||||||
|
then
|
||||||
echo "Creating ${ARG2} class ${CLASS_NAME} based on template ${TEMPLATE} and saving to ${R3_FOLDER}${FILE_NAME}"
|
echo "Creating ${ARG2} class ${CLASS_NAME} based on template ${TEMPLATE} and saving to ${R3_FOLDER}${FILE_NAME}"
|
||||||
fi
|
else
|
||||||
|
echo "Creating class ${CLASS_NAME} based on template ${TEMPLATE} extending ${EXTEND_CLASS} and saving to ${R3_FOLDER}${FILE_NAME}"
|
||||||
if [ "${ARG2}" = "system" ]; then
|
|
||||||
TEMPLATE="system_extends.template"
|
|
||||||
CLASS_NAME="${ARG1}"
|
|
||||||
FILE_NAME="r3$(echo "${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
|
||||||
INCLUDE_PATH="../$INCLUDE_PATH"
|
|
||||||
R3_FOLDER=$R3_SYSTEM_FOLDER
|
|
||||||
EXTEND_CLASS="System"
|
|
||||||
EXTEND_CLASS_FILE_NAME="r3$(echo "${EXTEND_CLASS}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
|
||||||
echo "Creating system ${CLASS_NAME} based on template ${TEMPLATE} extending ${EXTEND_CLASS} and saving to ${R3_FOLDER}${FILE_NAME}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${ARG2}" = "system_base" ]; then
|
|
||||||
TEMPLATE="system_base.template"
|
|
||||||
FILE_NAME="r3$(echo "${CLASS_NAME}" | sed 's/\([A-Z]\)/-\1/g' | awk '{print tolower($0)}').js"
|
|
||||||
INCLUDE_PATH="../$INCLUDE_PATH"
|
|
||||||
R3_FOLDER=$R3_SYSTEM_FOLDER
|
|
||||||
echo "Creating system ${CLASS_NAME} based on template ${TEMPLATE} extending ${EXTEND_CLASS} and saving to ${R3_FOLDER}${FILE_NAME}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "${TEMPLATE_FOLDER}${TEMPLATE}" "${R3_FOLDER}${FILE_NAME}"
|
cp "${TEMPLATE_FOLDER}${TEMPLATE}" "${R3_FOLDER}${FILE_NAME}"
|
||||||
|
@ -171,34 +163,6 @@ then
|
||||||
perl -p -i -e 's/^const Utils.*\n$//' "${R3_FOLDER}${FILE_NAME}"
|
perl -p -i -e 's/^const Utils.*\n$//' "${R3_FOLDER}${FILE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# grep 'GENERATED_' < "${TEMPLATE_FOLDER}"token.db | sed "s/^.*GENERATED/GENERATED/" | while IFS= read -r TOKEN
|
|
||||||
# do
|
|
||||||
#
|
|
||||||
# START_TOKEN="${TOKEN}_START"
|
|
||||||
# END_TOKEN="${TOKEN}_END"
|
|
||||||
# TEMPLATE=$(echo "${TOKEN}.template" | sed "s/^GENERATED_//" | awk '{print tolower($0)}')
|
|
||||||
#
|
|
||||||
# if grep -q "${START_TOKEN}" "${R3_FOLDER}${FILE_NAME}"; then
|
|
||||||
#
|
|
||||||
# if [ -f "${TEMPLATE_FOLDER}${TEMPLATE}" ]; then
|
|
||||||
#
|
|
||||||
# echo "Generating template ${TEMPLATE}"
|
|
||||||
#
|
|
||||||
# SPACE_COUNT=$(grep "${END_TOKEN}" "${R3_FOLDER}${FILE_NAME}" | perl -pe "s/^.*?(\s)/\1/" | perl -lne 'END {print $c} map ++$c, / /g')
|
|
||||||
# SPACES=''
|
|
||||||
#
|
|
||||||
# for ((i=0; i < SPACE_COUNT; i++)) do
|
|
||||||
# SPACES=" $SPACES"
|
|
||||||
# done
|
|
||||||
#
|
|
||||||
# # shellcheck disable=SC2002
|
|
||||||
# CONTENTS=$(cat "${TEMPLATE_FOLDER}${TEMPLATE}" | sed -E 's/([+,/,@])/\\\1/g')
|
|
||||||
# perl -i -pe "BEGIN{undef $/;} s/${START_TOKEN}.*\/\/${END_TOKEN}/${START_TOKEN}\n${CONTENTS}\n${SPACES}\/\/${END_TOKEN}/smg" "${R3_FOLDER}${FILE_NAME}"
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# done
|
|
||||||
|
|
||||||
INCLUDE_PATH=$(echo "${INCLUDE_PATH}" | sed -E 's/([+,/,@])/\\\1/g')
|
INCLUDE_PATH=$(echo "${INCLUDE_PATH}" | sed -E 's/([+,/,@])/\\\1/g')
|
||||||
|
|
||||||
sed -i "s/CLASS_NAME/${CLASS_NAME}/g" "${R3_FOLDER}${FILE_NAME}"
|
sed -i "s/CLASS_NAME/${CLASS_NAME}/g" "${R3_FOLDER}${FILE_NAME}"
|
||||||
|
|
Loading…
Reference in New Issue