#!/bin/bash

EXE=$(basename $0)
if [ "$1" == "--help" -o "$1" == "-h" ]; then
	echo "Syntax: $EXE [--force|-f] names ..."
	exit 0
fi
for DOC in $*; do
	if [ "$DOC" == "-f" -o "$DOC" == "--force" ]; then
		FORCE=yes
		continue
	elif [ "${DOC:0:1}" == "-" ]; then
		echo "$EXE: option '$DOC' not recognized"
		exit 1
	fi
	NAME=$(basename $DOC)
	FILE=docs/$DOC.md
	if [ -f "$FILE" -a ${FORCE:-no} == "no" ]; then
		echo "$EXE: document '$FILE' already exists" > /dev/stderr
		exit 2
	fi
	cat >$FILE <<END
[[/$DOC]] -- TODO one-line info on $NAME

# Synopsis
GLM:
~~~
TODO add GLM syntax for $NAME
~~~
Shell:
~~~
bash$ TODO add command-line syntax for $NAME
~~~

# Description

TODO add description of $NAME

## Subheading

TODO add details of options for $NAME

# Examples

TODO add one or more examples of using $NAME
~~~
example code goes here
~~~

# Caveats

1. TODO enumerate known issues using $NAME

# See also
* [[/Path/Document]]

END
done