diff options
Diffstat (limited to 'tool/make-usage.sh')
-rw-r--r-- | tool/make-usage.sh | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/tool/make-usage.sh b/tool/make-usage.sh index bc150a75..c9c890a2 100644 --- a/tool/make-usage.sh +++ b/tool/make-usage.sh @@ -1,5 +1,7 @@ #!/bin/sh +sq=$1 + quote() { sed 's@^@//! @' | sed 's/ $//' } @@ -12,30 +14,40 @@ end_code() { printf '```\n' } -( - printf "A command-line frontend for Sequoia. +dump_help() { # subcommand, indention + if [ -z "$1" ] + then + printf "\n# Usage\n\n" + set "" "#" + else + printf "\n$2 Subcommand$1\n\n" + fi -# Usage + help="`$sq $1 --help`" -" begin_code - sq --help + printf "$help\n" | tail -n +2 end_code - sq --help | - sed -n '/^SUBCOMMANDS:/,$p' | - tail -n+2 | - while read command desc - do - if [ "$command" = help ]; then - continue - fi - - printf "\n## Subcommand $command\n\n" - begin_code - sq $command --help - end_code - done + if echo $help | fgrep -q SUBCOMMANDS + then + printf "$help\n" | + sed -n '/^SUBCOMMANDS:/,$p' | + tail -n+2 | + while read subcommand desc + do + if [ "$subcommand" = help ]; then + continue + fi + + dump_help "$1 $subcommand" "#$2" + done + fi +} + +( + printf "A command-line frontend for Sequoia.\n" + dump_help ) | quote printf '\ninclude!("main.rs");\n' |