Skip to content

Commit d995b9b

Browse files
kpolaschekrauschhalostatue
authored andcommitted
Add script for generating table with ADR name and status
npryce#143
1 parent d927598 commit d995b9b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

src/_adr_generate_table

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
set -e
3+
eval "$($(dirname $0)/adr-config)"
4+
5+
## usage: adr generate table [-i INTRO] [-o OUTRO] [-p LINK_PREFIX]
6+
##
7+
## Generates a table in Markdown format to stdout that contains the ADR name
8+
## and status.
9+
##
10+
## Options:
11+
##
12+
## -i INTRO precede the table with the given INTRO text.
13+
## -o OUTRO follow the table with the given OUTRO text.
14+
## -p LINK_PREFIX
15+
## prefix each decision file link with LINK_PREFIX.
16+
##
17+
## Both INTRO and OUTRO must be in Markdown format.
18+
19+
args=$(getopt i:o:p: $*)
20+
set -- $args
21+
22+
link_prefix=
23+
24+
for arg
25+
do
26+
case "$arg"
27+
in
28+
-i)
29+
intro="$2"
30+
shift 2
31+
;;
32+
-o)
33+
outro="$2"
34+
shift 2
35+
;;
36+
-p)
37+
link_prefix="$2"
38+
shift 2
39+
;;
40+
--)
41+
shift
42+
break
43+
;;
44+
esac
45+
done
46+
47+
if [ ! -z $intro ]
48+
then
49+
cat "$intro"
50+
echo
51+
fi
52+
53+
echo "|ADR|Status|"
54+
echo "|---|---|"
55+
for f in $("$adr_bin_dir/adr-list")
56+
do
57+
title=$("$adr_bin_dir/_adr_title" $f)
58+
link=${link_prefix}$(basename $f)
59+
status=$("$adr_bin_dir/_adr_status" $f)
60+
61+
echo "|[$title]($link)|$status|"
62+
done
63+
64+
if [ ! -z $outro ]
65+
then
66+
echo
67+
cat "$outro"
68+
fi

0 commit comments

Comments
 (0)