#!/bin/bash
# Example script to link multiple action items to a Word document
# Usage: ./example_link_actions.sh actions.xlsx minutes.docx 003 004 005

EXCEL_FILE="${1:-actions.xlsx}"
WORD_FILE="${2:-minutes.docx}"

if [ "$#" -lt 3 ]; then
    echo "Usage: $0 <excel_file> <word_file> <action_no1> [action_no2] [action_no3] ..."
    echo "Example: $0 actions.xlsx minutes.docx 003 004 005"
    exit 1
fi

shift 2  # Remove first two arguments

echo "Linking action items to $WORD_FILE from $EXCEL_FILE"
echo "=========================================="

for ACTION_NO in "$@"; do
    echo ""
    echo "Processing Action No: $ACTION_NO"
    python link_excel_to_word.py \
        --excel "$EXCEL_FILE" \
        --word "$WORD_FILE" \
        --action-no "$ACTION_NO" \
        --table \
        --fields "Action Short Title,Who,Status,Priority,Next Action Deadline" \
        --placeholder "<<ACTION_${ACTION_NO}>>"
    
    if [ $? -eq 0 ]; then
        echo "✓ Successfully linked Action No $ACTION_NO"
    else
        echo "✗ Failed to link Action No $ACTION_NO"
    fi
done

echo ""
echo "=========================================="
echo "Done! Check your Word document for updated action items."





