Merge subcommand for k/v files
This commit is contained in:
		
							
								
								
									
										22
									
								
								shchemes
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								shchemes
									
									
									
									
									
								
							@@ -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]}"
 | 
			
		||||
      ;;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user