blob: bec96386ba192330014de0b818157e3f776c8fa1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/sh
tool=$1
quote() {
sed 's@^@//! @' | sed 's/ $//'
}
begin_code() {
printf '```text\n'
}
end_code() {
printf '```\n'
}
dump_help() { # subcommand, indention
if [ -z "$1" ]
then
printf "\n# Usage\n\n"
set "" "#"
else
printf "\n$2 Subcommand$1\n\n"
fi
help="`$tool $1 --help`"
begin_code
printf "$help\n" | tail -n +2
end_code
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!("'"$(basename $tool)"'.rs");\n'
|