#!/bin/bash # Regenerate docs/cmd/ from long help text set -euo pipefail rootdir="$(dirname $0)/.." prog="${rootdir}/target/${PROFILE:-debug}/coreos-installer" generate() { local subcommand subcommands subcommands=$("${prog}" $* -h | awk 'BEGIN {subcommands=0} /^$/ {if (subcommands) exit} {if (subcommands) print $1} /^Commands:$/ {subcommands=1}') # Generate TOC if this is a root command with subcommands if [ -n "${subcommands}" -a $# = 1 ]; then cat < "${path}.new" generate "$(basename ${path} .md)" >> "${path}.new" mv "${path}.new" "${path}" done