#!/bin/bash
#
# List plugins and their numbers.
# If no argument is passed, then the output is in LaTeX format
# Otherwise, tab separated.
#

if [ -n "$1" ]; then
    grep -RHi pluginorder= */autogen.sh | uniq | awk '{
        split($1, A, ":");
        split(A[1], B, "/");
        split(A[2], C, "=");
        printf "%s\t%s\n", B[1], C[2]
    }'
else
    grep -RHi pluginorder= */autogen.sh | uniq | awk '
        BEGIN{
            print "\\begin{center}\n\\begin{tabular}{l|c}\n{\\bf Plugin} & {\\bf Number} \\\\ \\hline"
        }
        {
    	    split($1, A, ":");
    	    split(A[1], B, "/");
    	    split(A[2], C, "=");
    	    printf "%s & %s\\\\\n", B[1], C[2];
        }
    	END {
            print "\\end{tabular}\n\\end{center}";
        }'
fi
