要打印帮助消息,我通常为此使用一个函数。因此,您可以在启动时或运行时使用它。例如:
void usage(char* progName)
{
cout << progName << "[options]" << endl <<
"Options:" << endl <<
"-h | --help Print this help" << endl <<
"-v | --version Print the SVN version" << endl <<
"-V | --Version Print the proxy version" << endl <<
"-d | --daemonize Run as daemon" << endl <<
"-P | --pidfile Path to PID file (default: " <<
WPASUP_PROXY_DEFAULT_PID_FILE << ")" << endl <<
"-l | --logging Path to logging file (default: " <<
WPASUP_PROXY_DEFAULT_LOGGING << ")" << endl <<
"-i | --ip The IP address of the main application (default: " <<
WPASUP_PROXY_MAIN_APP_IP << ")" << endl <<
"-p | --port The port number of the main application (default: " <<
WPASUP_PROXY_DEFAULT_MAIN_APP_PORT << ")" << endl <<
"-w | --wpa_cli Path to wpa_cli program (default: " <<
WPASUP_PROXY_DEFAULT_WPA_CLI << ")" << endl;
}
如果您愿意,您也可以使用 printf 函数......我认为这是一种常见的做法,但如果有人有更好的想法,我会很感兴趣!
问候!