Skip to content

Commit b6df631

Browse files
committed
Can define a project-specific template by creating a file called
<adr-dir>/templates/template.md.
1 parent aa86a8a commit b6df631

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

src/adr-new

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,16 @@ do
4646
esac
4747
done
4848

49-
template=${ADR_TEMPLATE:-"$adr_template_dir/template.md"}
5049
dstdir=$("$adr_bin_dir/_adr_dir")
50+
template="$ADR_TEMPLATE"
51+
if [ -z $template ]
52+
then
53+
template="$dstdir/templates/template.md"
54+
if [ ! -f "$template" ]
55+
then
56+
template="$adr_template_dir/template.md"
57+
fi
58+
fi
5159

5260
title="$@"
5361

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
+ adr init adrs
2+
adrs/0001-record-architecture-decisions.md
3+
+ mkdir -p adrs/templates
4+
+ cat
5+
+ adr new Aaa Bbb
6+
adrs/0002-aaa-bbb.md
7+
+ adr new Ccc Ddd
8+
adrs/0003-ccc-ddd.md
9+
+ cat adrs/0002-aaa-bbb.md
10+
# Aaa Bbb
11+
12+
Project specific template!
13+
14+
# Status
15+
16+
Accepted
17+
18+
# Info
19+
20+
ADR Number: 2
21+
22+
Date: 12/01/1992
23+
24+
+ cat adrs/0003-ccc-ddd.md
25+
# Ccc Ddd
26+
27+
Project specific template!
28+
29+
# Status
30+
31+
Accepted
32+
33+
# Info
34+
35+
ADR Number: 3
36+
37+
Date: 12/01/1992
38+

tests/project-specific-template.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
adr init adrs
2+
mkdir -p adrs/templates
3+
cat > adrs/templates/template.md <<EOF
4+
# TITLE
5+
6+
Project specific template!
7+
8+
# Status
9+
10+
STATUS
11+
12+
# Info
13+
14+
ADR Number: NUMBER
15+
16+
Date: DATE
17+
18+
EOF
19+
adr new Aaa Bbb
20+
adr new Ccc Ddd
21+
cat adrs/0002-aaa-bbb.md
22+
cat adrs/0003-ccc-ddd.md

0 commit comments

Comments
 (0)