如何从 getopt 生成帮助/使用说明?

如何从 getopt 生成帮助/使用说明?

有没有办法从中生成命令的“帮助”或“使用”信息getopt

像这样:

ARGUMENTS=$(getopt ... -- "$@")
echo $(help "$ARGUMENTS")

按此格式输出:

Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      with -l, scale sizes by SIZE when printing them;

相关内容