2021-06-09 04:10:24 +03:00
|
|
|
#!/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
|
|
|
|
|
2021-06-09 04:10:24 +03:00
|
|
|
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 04:10:24 +03:00
|
|
|
|
2021-06-09 18:49:52 +03:00
|
|
|
if [ -n "$intro" ];
|
2021-06-09 04:10:24 +03:00
|
|
|
then
|
|
|
|
cat "$intro"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
basedir=$(pwd -P)/decisions
|
|
|
|
|
2021-06-09 18:49:52 +03:00
|
|
|
for d in decisions/*/; do
|
2021-06-09 04:10:24 +03:00
|
|
|
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" ]
|
2021-06-09 04:10:24 +03:00
|
|
|
then
|
|
|
|
echo
|
|
|
|
cat "$outro"
|
|
|
|
fi
|