forked from npryce/adr-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
set -e | ||
eval "$($(dirname $0)/adr-config)" | ||
|
||
## usage: adr edit [ADR_NUMBER] | ||
|
||
## The last ADR, or the specified ADR NUMBER, is opened for | ||
## editing in the editor specified by the VISUAL or EDITOR | ||
## environment variable (VISUAL is preferred; EDITOR is | ||
## used if VISUAL is not set). | ||
|
||
if [ ! -z "$1" ] | ||
then | ||
editid=$(printf "%04d" $1) | ||
fi | ||
|
||
if [[ -z "$VISUAL" && -z "$EDITOR" ]] | ||
then | ||
echo "ERROR: editor not configured" | ||
exit 1 | ||
fi | ||
|
||
dstdir=$("$adr_bin_dir/_adr_dir") | ||
|
||
if [[ -d $dstdir && -z "$editid" ]] | ||
then | ||
editid=$(ls $dstdir | grep -Eo '^[0-9]+' | sort -rn | head -1) | ||
fi | ||
|
||
dstfile=$dstdir/$editid-*.md | ||
|
||
if [ -e $dstfile ] | ||
then | ||
${VISUAL:-${EDITOR:-true}} $dstfile | ||
else | ||
echo "ERROR: ADR $editid not found" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
adr init architecture-log | ||
architecture-log/0001-record-architecture-decisions.md | ||
adr new First Record | ||
architecture-log/0002-first-record.md | ||
|
||
export VISUAL | ||
export EDITOR | ||
|
||
if adr edit | ||
then | ||
echo ERROR: should have failed | ||
fi | ||
ERROR: editor not configured | ||
|
||
VISUAL= | ||
EDITOR=fake-editor | ||
adr edit | ||
EDITOR architecture-log/0002-first-record.md | ||
|
||
VISUAL=fake-visual | ||
EDITOR= | ||
adr edit | ||
VISUAL architecture-log/0002-first-record.md | ||
|
||
VISUAL=fake-visual | ||
EDITOR=fake-editor | ||
adr edit | ||
VISUAL architecture-log/0002-first-record.md | ||
|
||
adr edit 1 | ||
VISUAL architecture-log/0001-record-architecture-decisions.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
adr init architecture-log | ||
adr new First Record | ||
|
||
export VISUAL | ||
export EDITOR | ||
|
||
if adr edit | ||
then | ||
echo ERROR: should have failed | ||
fi | ||
|
||
VISUAL= | ||
EDITOR=fake-editor | ||
adr edit | ||
|
||
VISUAL=fake-visual | ||
EDITOR= | ||
adr edit | ||
|
||
VISUAL=fake-visual | ||
EDITOR=fake-editor | ||
adr edit | ||
|
||
adr edit 1 |