我正致力于开源贡献。我需要使用包含print_usage()
语句的printf()
函数来获取帮助消息(myprogram --help
),以便自动使用myprogram --man
生成联机帮助页。我已设置命令行参数以使用freopen()
将帮助消息直接打印到文件myprogram.1
。但是当使用man -l myprogram.1
执行时,它会改变行长度,这确实会改变输出的预期缩进。
帮助信息中的预期文字:
To see This Help Message: -h or --help
File name related options:
inputfile: file(s) to process
-o outputfilename: Use -o parameters to define output filename if you don't
like the default ones (same as infile plus _1 or _2 when
needed and file extension, e.g. .srt).
-cf filename: Write 'clean' data to a file. Cleans means the ES
without TS or PES headers.
-stdout: Write output to stdout (console) instead of file. If
stdout is used, then -o, -o1 and -o2 can't be used. Also
-stdout will redirect all messages to stderr (error).
执行man -l myprogram.1
时的输出:
To see This Help Message: ‐h or ‐‐help
File name related options:
inputfile: file(s) to process
‐o outputfilename: Use ‐o parameters to define output file‐
name if you don’t
like the default ones (same as infile plus
_1 or _2 when
needed and file extension, e.g. .srt).
‐cf filename: Write ’clean’ data to a file. Cleans means
the ES
without TS or PES headers.
‐stdout: Write output to stdout (console) instead
of file. If
stdout is used, then ‐o, ‐o1 and ‐o2 can’t
be used. Also
‐stdout will redirect all messages to
stderr (error).
我该如何纠正?我可以稍后通过C代码添加NAME,SYNOPSIS等部分,但目前我只需要正确的格式化。任何帮助表示赞赏。
修改
说清楚。获得的myprogram.1
不包含任何类型的groff
格式(不使用宏)。它只是纯文本文档,其帮助消息为带缩进的纯文本。