Skip to content

Commit ca4654b

Browse files
author
dmullis
committed
CHECKPOINT: code-gen to reduce count of GitHub user name in file content
1 parent 790e692 commit ca4654b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

cmd/goat/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import (
66
"log"
77
"os"
88

9+
// X Note that go.sum contains this:
10+
//
11+
// replace (
12+
// github.com/blampe/goat => /
13+
// )
14+
// X X This is not good enough for 'go get -u github.com/<other-user/goat'
915
"github.com/blampe/goat"
1016
)
1117

make.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,29 @@ usage () {
2020
svg_color_dark_scheme="#EEF"
2121
svg_color_light_scheme="#011"
2222

23+
GOMOD=$(go env GOMOD)
24+
from_username=${GOMOD##*github.com/}
25+
githubuser=${from_username%%/*}
26+
2327
TEST_ARGS=
2428

2529
while getopts hg:iw flag
2630
do
2731
case $flag in
2832
h) usage "";;
29-
g) githubuser=${OPTARG};; # XX At present only controls local debug output via `marked`
33+
g) githubuser=${OPTARG};; # Override guess based on GOMOD
3034
w) TEST_ARGS=${TEST_ARGS}" -write";;
3135
\?) usage "unrecognized option flag";;
3236
esac
3337
done
3438

39+
tmpl_expand () {
40+
go run ./cmd/tmpl-expand Root="." GithubUser=${githubuser} "$@"
41+
}
42+
43+
#tmpl_expand <go.tmpl.mod >go.mod
44+
#tmpl_expand <./cmd/goat/main.tmpl.go >./cmd/goat/main.go
45+
3546
# SVG examples/ regeneration.
3647
#
3748
# If the command fails due to expected changes in SVG output, rerun
@@ -42,7 +53,7 @@ go test -run . -v \
4253
${TEST_ARGS}
4354

4455
# build README.md
45-
go run ./cmd/tmpl-expand Root="." <README.md.tmpl >README.md \
56+
tmpl_expand <README.md.tmpl >README.md \
4657
$(bash -c 'echo ./examples/{trees,overlaps,line-decorations,line-ends,dot-grids,large-nodes,small-grids,big-grids,complicated}.{txt,svg}')
4758

4859
# '-d' writes ./awkvars.out
@@ -57,9 +68,6 @@ cat *.go |
5768
-svg-color-light-scheme ${svg_color_light_scheme} \
5869
>goat.svg
5970

60-
if [ ! "$githubuser" ] # XX Is this the right test
61-
then
62-
# Render to HTML, for local inspection.
63-
./markdown_to_html.sh README.md >README.html
64-
./markdown_to_html.sh CHANGELOG.md >CHANGELOG.html
65-
fi
71+
# Render to HTML, for local inspection.
72+
./markdown_to_html.sh README.md >README.html
73+
./markdown_to_html.sh CHANGELOG.md >CHANGELOG.html

0 commit comments

Comments
 (0)