File tree Expand file tree Collapse file tree 6 files changed +48
-13
lines changed
Expand file tree Collapse file tree 6 files changed +48
-13
lines changed Original file line number Diff line number Diff line change @@ -9,22 +9,27 @@ eval "$("$(dirname "$0")"/adr-config)"
99# # Options:
1010# #
1111# # -s include the state of each decision next to its link.
12- # # -i INTRO precede the table of contents with text from the INTRO file .
13- # # -o OUTRO follow the table of contents with text from the given OUTRO file .
12+ # # -i INTRO precede the table of contents with the given INTRO text .
13+ # # -o OUTRO follow the table of contents with the given OUTRO text .
1414# # -p LINK_PREFIX
1515# # prefix each decision file link with LINK_PREFIX.
16+ # # -r list the records in reverse order
1617# #
1718# # Both INTRO and OUTRO must be in Markdown format.
1819
1920link_prefix=
2021output_status=
22+ list_args=()
2123
22- while getopts si :o:p: arg; do
24+ while getopts rsi :o:p: arg; do
2325 case " $arg " in
2426 s)
2527 output_status=1
2628 shift
2729 ;;
30+ r)
31+ list_args+=(" -r" )
32+ ;;
2833 i)
2934 intro=" $OPTARG "
3035 ;;
@@ -42,13 +47,12 @@ cat <<EOF
4247
4348EOF
4449
45- if [ -n " $intro " ]
46- then
47- cat " $intro "
48- echo
50+ if [ -n " $intro " ]; then
51+ cat " $intro "
52+ echo
4953fi
5054
51- for f in $( " $adr_bin_dir /adr-list" ) ; do
55+ for f in $( " $adr_bin_dir /adr-list" " ${list_args[@]} " ) ; do
5256 title=$( " $adr_bin_dir /_adr_title" " $f " )
5357 link=${link_prefix} $( basename " $f " )
5458 status=
@@ -68,4 +72,3 @@ if [ ! -z "$outro" ]; then
6872 echo
6973 cat " $outro "
7074fi
71-
Original file line number Diff line number Diff line change 22set -e
33eval " $( " $( dirname " $0 " ) " /adr-config) "
44
5- # # usage: adr list
5+ # # usage: adr list [-r]
66# #
77# # Lists the architecture decision records
8+ # #
9+ # # Options:
10+ # #
11+ # # -r list decision records in reverse order
812
913adr_dir=" $( " $adr_bin_dir /_adr_dir" ) "
1014
15+ sort_args=()
16+
17+ if (( $# > 0 )) ; then
18+ while getopts " :r" arg; do
19+ case " ${arg} " in
20+ r)
21+ sort_args+=(" -r" )
22+ ;;
23+
24+ * )
25+ echo " invalid argument: $OPTARG " >&2
26+ exit 1
27+ ;;
28+ esac
29+ done
30+ shift $(( OPTIND- 1 ))
31+ fi
32+
1133if [ -d " $adr_dir " ]
1234then
13- find " $adr_dir " -maxdepth 1 -type f | grep -E " ^.{ ${ # adr_dir} } /[0-9]*[1-9][0-9]*-[ ^/]*\\ .md$ " | sort
35+ find " $adr_dir " | grep -E " ^$ adr_dir /[0-9]+-[ ^/]*\\ .md" | sort " ${sort_args[@]} "
1436else
1537 echo " The $adr_dir directory does not exist"
1638 exit 1
Original file line number Diff line number Diff line change @@ -10,3 +10,9 @@ adr generate toc
1010* [1. First Decision](0001-first-decision.md)
1111* [2. Second Decision](0002-second-decision.md)
1212* [3. Third Decision](0003-third-decision.md)
13+ adr generate toc -r
14+ # Architecture Decision Records
15+
16+ * [3. Third Decision](0003-third-decision.md)
17+ * [2. Second Decision](0002-second-decision.md)
18+ * [1. First Decision](0001-first-decision.md)
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ adr new First Decision
22adr new Second Decision
33adr new Third Decision
44adr generate toc
5+ adr generate toc -r
Original file line number Diff line number Diff line change @@ -15,4 +15,7 @@ adr list
1515doc/adr/0001-first.md
1616doc/adr/0002-second.md
1717doc/adr/0003-third.md
18-
18+ adr list -r
19+ doc/adr/0003-third.md
20+ doc/adr/0002-second.md
21+ doc/adr/0001-first.md
Original file line number Diff line number Diff line change @@ -5,4 +5,4 @@ adr new second
55adr list
66adr new third
77adr list
8-
8+ adr list -r
You can’t perform that action at this time.
0 commit comments