Merge subcommand for k/v files

This commit is contained in:
Dakedres 2025-05-12 16:09:28 -06:00
parent cd63d6d236
commit 83a2f25c15

View File

@ -170,6 +170,24 @@ ENDFILE {
' "$path" > "$tmp" && mv "$tmp" "$path"
}
# TODO: multiple format support, check that line actually has multiple fields
merge() {
path=$1
tmp=$(mktemp)
awk -F "=" '
FILENAME == "-" {
a[$1] = $2
next
}
a[$1] {
print $1 "=" a[$1]
next
}
{ print }
' - "$path" > "$tmp" && mv "$tmp" "$path"
}
convert_tinted_scheme() {
path=$1
tmp=$(mktemp)
@ -247,6 +265,10 @@ if [ "$method" != "" ]; then
inject "${args[1]}" "${args[2]}"
;;
merge)
merge "${args[1]}" "${args[2]}"
;;
convert_tinted_template)
convert_tinted_template "${args[1]}"
;;