Skip to content

Commit

Permalink
simplify generate-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Jan 14, 2021
1 parent 97ca34c commit 262e878
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions script/generate-readme
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ set -e
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")"

cmd_readme() {
cmd_name="$1"
cat <<EOF >"./cmd/$cmd_name/README.md"
cmd_dir="$1"
cmd_name="$(basename "$cmd_dir")"
cat <<EOF >"$cmd_dir/README.md"
## $cmd_name
### Install
Expand Down Expand Up @@ -35,24 +36,22 @@ $("script/$cmd_name" --help)
EOF
}

cmd_readme eventbridge-pipe
cmd_readme eventgrid-pipe
cmd_readme splunk-pipe

line_no="$(grep -n \
'<!--- Past here is generated by generate-readme DO NOT EDIT --->' \
README.md | cut -d: -f1)"

readme="$(head -"$line_no" ./README.md)"
{
echo "$readme"

printf "\n---\n\n"
cat ./cmd/eventbridge-pipe/README.md
for cmd_dir in ./cmd/*; do
cmd_readme "$cmd_dir"

readme="$readme
---
$(cat "$cmd_dir/README.md")
"

printf "\n---\n\n"
cat ./cmd/eventgrid-pipe/README.md
done

printf "\n---\n\n"
cat ./cmd/splunk-pipe/README.md
} > ./README.md
echo "$readme" > ./README.md

0 comments on commit 262e878

Please sign in to comment.