#!/bin/bash

# Define an empty string to hold the result
result=$'Consider the following source code:\n'

# 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 -name "*.png" -o -name "LICENSE" -o -name $(basename "$0") -o -path "*/tmp/*" \) -print0)

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