-
Notifications
You must be signed in to change notification settings - Fork 1
/
help.sh
executable file
·34 lines (30 loc) · 1.03 KB
/
help.sh
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
#!/bin/bash
# generate markdown files in subdirectory "help" from cli help screens
name="orcli"
orcli() {
./orcli "$@"
}
version="$(${name} --version)"
files=(src/*_command.sh)
for f in "${files[@]}"; do
command="${f#src/}"
command="${command%_command.sh}"
commands+=( "${command}" )
done
mkdir -p help
for command in "${commands[@]}"; do
{ echo "# ${name} ${command//_/ }"; } > help/"${command}".md
{ echo; echo '```'; } >> help/"${command}".md
${name} ${command//_/ } --help >> help/"${command}".md
{ echo '```'; echo; } >> help/"${command}".md
echo "code: [src/${command}_command.sh](../src/${command}_command.sh)" >> help/"${command}".md
done
{ echo "# ${name} ${version}"; echo; } > help/README.md
{ echo '## command help screens'; echo; } >> help/README.md
for command in "${commands[@]}"; do
echo "- [${command//_/ }](${command}.md)" >> help/README.md
done
{ echo; echo '## main help screen'; } >> help/README.md
{ echo; echo '```'; } >> help/README.md
${name} --help >> help/README.md
echo '```' >> help/README.md