سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top