Question

I created a man page for my C++ application and I would like to show it to the user when a particular flag is specified in the command line. Is system("man myapplication") the only way to do this, or are there any better options?

Was it helpful?

Solution

I'd probably take the nroff (text) output of man and stick it either in the code as one huge string or in a separate file depending on how many pieces the program installs with.

Calling system("man") requires a lot of dependencies which is the last thing your unfortunate user wants to deal with after typing my_program --long-help. It would work just fine in many cases, but when it didn't you'd lose an important feature of your program and have to report the rather silly "sorry: no long help available".

This would also increase portability to systems that never had a man program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top