#!/bin/bash

# Check if the input file is provided as the first argument
if [[ -z "$1" ]]; then
    exit 1
fi

# Input file
input_file="$1"

# Temporary variables
current_name=""
current_type="none"
current_lookup="none"

# Process the input file line by line
while IFS= read -r line; do
    # Check for PropertyMetadata name
    if [[ $line =~ new\ PropertyMetadata\(\s*\'([^\']+)\' ]]; then
        # If there's an existing property, print it before moving to the next
        if [[ -n $current_name ]]; then
            echo "$current_name:$current_type:$current_lookup"
        fi
        # Start a new property
        current_name="${BASH_REMATCH[1]}"
        current_type="none"
        current_lookup="none"  # Reset lookup for the new block
    fi

    # Check for displayAdapterType
    if [[ $line =~ displayAdapterType:\ DisplayAdapterType\.([A-Za-z]+) ]]; then
        current_type="${BASH_REMATCH[1]}"
    fi

    # Check for lookupProviderKey
    if [[ $line =~ lookupProviderKey:\ \'([^\']+)\' ]]; then
        current_lookup="${BASH_REMATCH[1]}"
    fi
done < "$input_file"

# Print the last property
if [[ -n $current_name ]]; then
    echo "$current_name:$current_type:$current_lookup"
fi

