sre-adrs/generate_toc.sh

47 строки
746 B
Bash
Исходник Постоянная ссылка Обычный вид История

#!/bin/bash
2021-06-09 04:25:57 +03:00
# adapted from https://github.com/npryce/adr-tools
# a combination of a few scripts, _adr_title, _adr_generate_toc
set -e
args=$(getopt i:o:p: $*)
set -- $args
link_prefix=./decisions/
eval "$(adr config)"
2021-06-09 18:49:52 +03:00
echo "# Architecture Decision Records"
2021-06-09 18:49:52 +03:00
if [ -n "$intro" ];
then
cat "$intro"
echo
fi
basedir=$(pwd -P)/decisions
2021-06-09 18:49:52 +03:00
for d in decisions/*/; do
if ! [[ $d -ef $basedir ]]; then
echo -e "\n\n## $(basename $d)"
for f in $(find $d -name '*.md'| grep -E "/[0-9]+-[^/]*\\.md" | sort)
do
title=$(head -1 "$f" | cut -c 3-)
link=${link_prefix}$(basename $d)/$(basename $f)
echo "* [$title]($link)"
done
fi
done
2021-06-09 18:49:52 +03:00
if [ -n "$outro" ]
then
echo
cat "$outro"
fi