Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for adding table that contains ADR name and status #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/_adr_generate_table
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
set -e
eval "$($(dirname $0)/adr-config)"

## usage: adr generate table [-i INTRO] [-o OUTRO] [-p LINK_PREFIX]
##
## Generates a table in Markdown format to stdout that contains the ADR name and status.
##
## Options:
##
## -i INTRO precede the table with the given INTRO text.
## -o OUTRO follow the table with the given OUTRO text.
## -p LINK_PREFIX
## prefix each decision file link with LINK_PREFIX.
##
## Both INTRO and OUTRO must be in Markdown format.

args=$(getopt i:o:p: $*)
set -- $args

link_prefix=

for arg
do
case "$arg"
in
-i)
intro="$2"
shift 2
;;
-o)
outro="$2"
shift 2
;;
-p)
link_prefix="$2"
shift 2
;;
--)
shift
break
;;
esac
done

if [ ! -z $intro ]
then
cat "$intro"
echo
fi

echo "|ADR|Status|"
echo "|---|---|"
for f in $("$adr_bin_dir/adr-list")
do
title=$("$adr_bin_dir/_adr_title" $f)
link=${link_prefix}$(basename $f)
status=$("$adr_bin_dir/_adr_status" $f)

echo "|[$title]($link)|$status|"
done

if [ ! -z $outro ]
then
echo
cat "$outro"
fi