You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
494 B

  1. # -*- mode: shell-script -*-
  2. yaml_opt_flatten() {
  3. local prefix="$1" key value
  4. while read-0 key value; do
  5. if [ "$prefix" ]; then
  6. new_prefix="${prefix}-${key}"
  7. else
  8. new_prefix="${key}"
  9. fi
  10. if [[ "$(echo "$value" | shyaml get-type)" == "struct" ]]; then
  11. echo "$value" | yaml_opt_flatten "${new_prefix}"
  12. else
  13. printf "%s\0%s\0" "${new_prefix}" "$value"
  14. fi
  15. done < <(shyaml key-values-0)
  16. }