#!/bin/bash

# Define an empty string to hold the result
result="Consider the following source code"

# Use a while loop to read the find output line by line
while IFS= read -r -d $'\0' file; do
    # remove trailing ./ from the filename
    file="${file#./}"

    # Use sed to remove the license text and append the modified file contents to the result string
    modified_content=$(cat "$file")

    result+="
${file}:
\`\`\`
$modified_content
\`\`\`
"
done < <(find . -type f -not \( -path "./.git/*" -o -path "./.github/*" -o -path "./node_modules/*" -o -path "./.idea/*" -o -name "*.png" -o -name "LICENSE" -o -name ".DS_Store" -o -name "*.lock" -o -name "package-lock.json" \) -print0)

# Pipe the result into pbcopy
echo "$result" | pbcopy
