added possibility to document template parameters

master
Marc Wäckerlin 7 years ago
parent 5c338d1692
commit b2337212d2
  1. 25
      template.sh

@ -3,8 +3,9 @@
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
(-h|--help) if test -e "${!#}"; then (-h|--help) if test -e "${!#}"; then
sed -n 's,^ *# \( *[^-]\),\1,p' "${!#}"
cat <<EOF cat <<EOF
$0 $(sed -n 's,^ *# *,,p' "${!#}" | tr '\n' ' ') ${!#} $0 $(sed -n 's,^ *# \+-,-,p' "${!#}" | tr '\n' ' ') ${!#}
EOF EOF
else else
cat <<EOF cat <<EOF
@ -26,8 +27,19 @@ FILE
and execute bash commands, e.g. you are allowed wo use the \$() and execute bash commands, e.g. you are allowed wo use the \$()
expression. expression.
Document the parameters that shall be used in comment lines, this Document the template and the parameters that in comment
are lines thet start with # followed by -v or -p options. lines. Comment lines that start with a hash and a space ("# "). If
a dash ("-") follows, then this line documents a parameter.
Example:
# this is an arbitrary documentation line that is copied
# these are the parameters:
#
# -v VAR1=
# -v VAR2=
# -p PWD1
# -p PWD2
DESCRIPTION DESCRIPTION
@ -39,9 +51,10 @@ EXAMPLE
file wordpress.tpl file wordpress.tpl
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
# -v NAME= # this templeate starts a wordpress given an name and a port
# -v PORT= # -v NAME=
# -p PASSWORD # -v PORT=
# -p PASSWORD
version: '3.3' version: '3.3'
services: services:
mysql: mysql:

Loading…
Cancel
Save