#!/bin/bash

# Check if the input file is provided
if [ "$#" -lt 1 ]; then
    echo "Usage: $0 <input-file> <n>"
    exit 1
fi

input_file="$1"
input_N="${2:-1}"


for ((i=0; i<input_N; i++)); do
cat << EOF
        {
EOF

$(dirname "$0")/enculumedParseMetadata.bash "$input_file" | while IFS= read -r line; do
    IFS=':' read -r name type lookup <<< "$line"
    #echo " $name $type $lookup"
    if [[ $name = *Id ]]; then
        echo "            $name: $i,"
    elif [[ $name = *Key ]]; then
        echo "            $name: '$name',"
    elif [[ "$type" == @(Text|RichText|Navigation|AutoComplete|TextArea) ]]; then
        echo "            $name: '$name',"
    elif [[ "$type" == @(ComboBox|CheckBox|CheckBoxThreeState) ]]; then
        echo "            $name: '$name',"
    elif [[ "$type" == @(Integer|Decimal|DurationInputMinutes|DurationInputHours) ]]; then
        echo "            $name: $i,"
    elif [[ "$type" == @(Date|DateTime) ]]; then
        echo "            $name: new Date(),"
    elif [[ "$type" == "Radio" ]]; then
        echo "            $name: true,"
    elif [[ "$type" == @(PickList|CheckList|PickListLeftRight|MultilineChecklist|MultilinePickList|ItemsPickerFieldset) ]]; then
        echo "            $name: [],"
    elif [[ "$type" == @(Table|EditableTable|ButtonToggleGroup|FormList) ]]; then
        echo "            $name: [],"
    elif [[ "$type" == @(Form|Interval|DoubleRange|DateTimeInterval) ]]; then
        echo "            $name: {},"
    elif [[ -n "$type" ]]; then
        echo "            $name: null,"
    fi
done

cat << EOF
        },
EOF

done


: <<'COMMENT'


export enum DisplayAdapterType {
    None = 0,
    Password = 21,
    NewPassword = 33,

Text|RichText|Navigation|AutoComplete|TextArea

Integer|Decimal|DurationInputMinutes|DurationInputHours

Date|DateTime

Radio = 20,

ComboBox|CheckBox|CheckBoxThreeState


PickList|CheckList|PickListLeftRight|MultilineChecklist|MultilinePickList|ItemsPickerFieldset|

Form|Interval|DoubleRange|DateTimeInterval

Table|EditableTable|ButtonToggleGroup|FormList
}

COMMENT


