#!/bin/bash USAGE="test_lang.sh lang-file-root-path file-target file-format-extension format-output section-or-all" [ "$1" == "-h" ] && echo "$USAGE" && exit [ -r "$1" ] && DATA_LANG_PATH=$1 if [ -z "$DATA_LANG_PATH" ] && [ -r "es.yaml" ] ; then DATA_LANG_PATH="." DATA_LANG_TARGET="es" DATA_LANG_FORMAT="yaml" fi [ -n "$2" ] && [ -z "$DATA_LANG_TARGET" ] && DATA_LANG_TARGET=$2 [ -n "$3" ] && [ -z "$DATA_LANG_FORMAT" ] && DATA_LANG_FORMAT=$3 [ -z "$DATA_LANG_PATH" ] && echo -n "Root path for lang: " && read -r DATA_LANG_PATH && echo "" [ -z "$DATA_LANG_TARGET" ] && echo -n "Target for lang: " && read -r DATA_LANG_PATH && echo "" format=$(basename "$DATA_LANG_TARGET" | cut -f2 -d".") [ -n "$format" ] && DATA_LANG_TARGET=$(echo "$DATA_LANG_TARGET" | cut -f1 -d"."); if [ -z "$DATA_LANG_FORMAT" ] ;then echo -ne "Path: $DATA_LANG_PATH\nformat (yaml,toml,json): $format [ENTER or change] " read -r DATA_LANG_FORMAT && echo "" fi case "$DATA_LANG_FORMAT" in yaml|YAML) DATA_LANG_FORMAT="yaml" ;; toml|TOML) DATA_LANG_FORMAT="toml" ;; json|JSON) DATA_LANG_FORMAT="json" ;; *) DATA_LANG_FORMAT=$format # echo "Format \"$DATA_LANG_FORMAT\" not defined" && exit 1 esac [ ! -r "$DATA_LANG_PATH/$DATA_LANG_TARGET.$DATA_LANG_FORMAT" ] && echo "$DATA_LANG_PATH/$DATA_LANG_TARGET.$DATA_LANG_FORMAT not found" && exit 1 [ -n "$4" ] && DATA_LANG_OUT_FORMAT=$4 out_format=$format if [ -z "$DATA_LANG_OUT_FORMAT" ] ;then echo -ne "Path: $DATA_LANG_PATH\nOUTPUT format (yaml,toml,json): $out_format [ENTER or change] " read -r DATA_LANG_OUT_FORMAT && echo "" fi case "$DATA_LANG_OUT_FORMAT" in yaml|YAML) DATA_LANG_OUT_FORMAT="yaml" ;; toml|TOML) DATA_LANG_OUT_FORMAT="toml" ;; json|JSON) DATA_LANG_OUT_FORMAT="json" ;; -) DATA_LANG_OUT_FORMAT="" ;; *) echo "Format \"$DATA_LANG_FORMAT\" " #DATA_LANG_OUT_FORMAT=$out_format esac [ -n "$5" ] && DATA_LANG_SECTION=$5 export DATA_LANG_PATH export DATA_LANG_TARGET export DATA_LANG_FORMAT export DATA_LANG_SECTION export DATA_LANG_OUT_FORMAT cargo test load_lang -- --nocapture