Skip to content

Instantly share code, notes, and snippets.

@rasmusmerzin
Last active November 26, 2020 15:32
Show Gist options
  • Save rasmusmerzin/b570532c7cc15f1feeeb46a1fb2aa9eb to your computer and use it in GitHub Desktop.
Save rasmusmerzin/b570532c7cc15f1feeeb46a1fb2aa9eb to your computer and use it in GitHub Desktop.
#!/bin/bash
echo '## Operators'
"$@" help | awk '
BEGIN {
doprint = 0
}
/^\s*$/ {
doprint = 0
}
{
if (doprint) print $1
}
/SUBCOMMANDS/ {
doprint = 1
}
' | while read -r operator
do
printf '\n### %s\n' "$operator"
"$@" help "$operator" | awk '
{
switch (NR) {
case 1: break
case 2:
print "\n"$0"\n"
break
default:
if (length($0) > 0)
print " "$0
}
}
'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment