#!/bin/bash

if [ $# -gt 0 ]; then
    if [[ "$1" == "-lang" || "$1" == "-l" ]]; then
        lang=$2
    else
        lang=cpp
    fi
else
    lang=cpp
fi

count=0
while [ $# -gt 0 ]; do
    file=$1
    shift

    if [ -e "$file" ]; then
        echo -e "\n\n$file:\n\n"
        pygmentize -l $lang $file |cat -n
        ((++count))
    else
        echo -e "\nCannot find file ($file).  Please check your spelling."
    fi
done

if [ $count -eq 0 ]; then
    echo "Please tell me the name(s) of the source file(s) to display."
    echo ""
    echo "The language can be specified with -l or -lang and the language"
    echo "abbreviation as the first two arguments.  The language abbreviations"
    echo "are:"
    echo ""
    echo -e "\tc for C"
    echo -e "\tcpp for C++"
    echo -e "\tjava for Java"
    echo -e "\tasm for Assembly"
    echo ""
fi
