generate_manpages.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/Shell
  2. export ARGSPARSER_EMIT_MARKDOWN=1
  3. # Qemu likes to start us in the middle of a line, so:
  4. echo
  5. ERROR_FILE="generate_manpages_error.log"
  6. rm -f "$ERROR_FILE"
  7. exit_for_error()
  8. {
  9. if test $DO_SHUTDOWN_AFTER_GENERATE {
  10. touch "$ERROR_FILE" # Ensure it exists, in case there wasn't any stderr output.
  11. shutdown -n
  12. } else {
  13. exit 1
  14. }
  15. }
  16. rm -rf generated_manpages 2> "$ERROR_FILE" || exit_for_error
  17. # FIXME: Add `UserspaceEmulator 1` back to this list after UE is functional on x86_64.
  18. for i in ( \
  19. (config 1) \
  20. (fortune 1) \
  21. (grep 1) \
  22. (nc 1) \
  23. (nl 1) \
  24. (passwd 1) \
  25. (readelf 1) \
  26. (shot 1) \
  27. (sql 1) \
  28. (strace 1) \
  29. (tr 1) \
  30. (traceroute 1) \
  31. (truncate 1) \
  32. ) {
  33. filename="generated_manpages/man$i[1]/$i[0].md"
  34. mkdir -p "generated_manpages/man$i[1]"
  35. echo "Generating for $i[0] in $filename ..."
  36. $i[0] --help > "$filename" 2> "$ERROR_FILE" || exit_for_error
  37. echo -e "\n<!-- Auto-generated through ArgsParser -->" >> "$filename" 2> "$ERROR_FILE" || exit_for_error
  38. }
  39. rm -f "$ERROR_FILE"
  40. echo "Successful."
  41. if test $DO_SHUTDOWN_AFTER_GENERATE {
  42. shutdown -n
  43. }