ngs
ngs copied to clipboard
Integrate TOML parser and generator
Similar to https://github.com/ngs-lang/ngs/issues/217
Example of bash to extract a field:
#!/usr/bin/env bash
FILE=$1
KEY=$2
while read line;do
if [[ $line =~ ^\[([^\ ]+)\ *\]$ ]];then
section="${BASH_REMATCH[1]}"
continue
fi
if [[ $line =~ ^([^=\ ]*)\ *=\ *\"(.*)\"\ *$ ]];then
k="${section}.${BASH_REMATCH[1]}"
if [[ $k == $KEY ]];then
echo "${BASH_REMATCH[2]}"
exit 0
fi
fi
done < "$FILE"
exit 1