ngs icon indicating copy to clipboard operation
ngs copied to clipboard

Integrate TOML parser and generator

Open organom opened this issue 3 years ago • 1 comments

Similar to https://github.com/ngs-lang/ngs/issues/217

organom avatar Dec 14 '21 12:12 organom

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

organom avatar Mar 03 '22 10:03 organom