I'm working on an Open Source contribution. I need to use its print_usage()
function which contains printf()
statements for help message (myprogram --help
) to generate manpage using myprogram --man
automatically. I've setup command line args to use freopen()
to print the help message directly to file myprogram.1
. But when executed with man -l myprogram.1
it changes the line length which indeed changes the output's expected indentation.
Expected text as in help message:
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).
Output when man -l myprogram.1
is executed:
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).
How can I correct this? I can add sections like NAME, SYNOPSIS, etc. through C code later on but currently I just need to get the formatting right. Any help is appreciated.
EDIT
To make it clear. myprogram.1
obtained doesn't contain any type of groff
formatting (no macros are used). It's just plain text document having the help message as plain text with indentation.