I plan to use pandoc
to generate the man
files from markdown for a very small C program.
I do not want to repeat myself and type the help prompt (command [ -h | --help ]
) into the source code of the program.
Question
Q: Could I permanently include man content from a file at compile time of a C program?
OR
Q: Is there a way in C to print the contents of the installed man page to stdout?
[WIP] Solution
Based on @KamilCuk's answer here's what i am doing:
In terminal:
file command.1 # OUTPUT --> command.1: troff or preprocessor input, ASCII text xxd -i command.1 > command.hex
Then in main.c
#include "command.hex" printf("%s", command_1);
This is almost exactly what I am looking for except
- I need the hexed troff to be parsed before printing. Or parsed before hexing. I am not sure which to do / how to do that.
- No, I do not want to call
man
and pipe the output.
- No, I do not want to call
- I would prefer using a library + a macro to generate the hex but I am not sure how it's done.
Clarifications
What I mean by help prompt:
- The output of
git --help
which prints to stdout - NOT the output of
git --help branch
which opens the man for git-branch
However, please do share the latter too. It isn't what I want: my manual is very short; but I would be glad to learn an alternative if not the exact one I seek.
Considerations I have noted:
- man pages are not always installed to the same location
- man pages may not be installed in some systems; or there may be no
man
program
没有评论:
发表评论