Created
February 18, 2017 21:33
-
-
Save gdvalle/c98dce649818c775a5be3db2488360bc to your computer and use it in GitHub Desktop.
Replace text between invisible markdown comments.
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
#!/usr/bin/env bash | |
# This just replaces the text between a couple of hopefully invisible | |
# markdown comments, like so: `[//]: #` (text within backticks) | |
set -euo pipefail | |
main_output="$(cargo run -- --help)" | |
output="$(printf "### main\n\`\`\`\n%s\n\`\`\`" "$main_output")\n" | |
output+="### subcommands\n" | |
for subcmd in subcmd1 subcmd2; do | |
subcmd_output="$(cargo run -- "$subcmd" --help)" | |
output+="$(printf "#### %s\n\`\`\`\n%s\n\`\`\`" "$subcmd" "$subcmd_output")\n" | |
done | |
perl -i -pe "BEGIN{undef $/;} s@\[//\]: #\n.*\[//\]: #\$@[//]: #\n${output}[//]: #@smg" README.md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment