summaryrefslogtreecommitdiff
path: root/Base/root/generate_manpages.sh
blob: a6a857dd231c73f42612e8c726a8cfd691fd95e7 (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
54
55
56
57
58
59
#!/bin/Shell

export ARGSPARSER_EMIT_MARKDOWN=1

# Qemu likes to start us in the middle of a line, so:
echo

ERROR_FILE="generate_manpages_error.log"
rm -f "$ERROR_FILE"

exit_for_error()
{
    if test $DO_SHUTDOWN_AFTER_GENERATE {
        touch "$ERROR_FILE" # Ensure it exists, in case there wasn't any stderr output.
        shutdown -n
    } else {
        exit 1
    }
}

rm -rf generated_manpages 2> "$ERROR_FILE" || exit_for_error

# FIXME: Add `UserspaceEmulator 1` back to this list after UE is functional on x86_64.
for i in ( \
            (config 1) \
            (fortune 1) \
            (grep 1) \
            (gunzip 1) \
            (gzip 1) \
            (ifconfig 1) \
            (lsof 1) \
            (nc 1) \
            (netstat 1) \
            (nl 1) \
            (ntpquery 1) \
            (passwd 1) \
            (readelf 1) \
            (shot 1) \
            (sql 1) \
            (strace 1) \
            (tr 1) \
            (traceroute 1) \
            (tree 1) \
            (truncate 1) \
            (utmpupdate 1) \
        ) {
    filename="generated_manpages/man$i[1]/$i[0].md"
    mkdir -p "generated_manpages/man$i[1]"
    echo "Generating for $i[0] in $filename ..."
    $i[0] --help > "$filename" 2> "$ERROR_FILE" || exit_for_error
    echo -e "\n<!-- Auto-generated through ArgsParser -->"  >> "$filename" 2> "$ERROR_FILE" || exit_for_error
}

rm -f "$ERROR_FILE"
echo "Successful."

if test $DO_SHUTDOWN_AFTER_GENERATE {
    shutdown -n
}