src: Format help message and add --version to make man page generation easier
This commit is contained in:
parent
1fd5fdd54a
commit
f5342494f4
|
@ -1654,14 +1654,18 @@ int run(char **uris, int n)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void print_version(std::ostream& out)
|
||||
{
|
||||
out << "nghttp nghttp2/" NGHTTP2_VERSION << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void print_usage(std::ostream& out)
|
||||
{
|
||||
out << "Usage: nghttp [-Oansuv] [-t <SECONDS>] [-w <WINDOW_BITS>] [-W <WINDOW_BITS>]\n"
|
||||
<< " [--cert=<CERT>] [--key=<KEY>] [-d <FILE>] [-m <N>]\n"
|
||||
<< " [-p <PRIORITY>] [-M <N>] [-b <ALIGNMENT>]\n"
|
||||
<< " <URI>..."
|
||||
<< std::endl;
|
||||
out << "Usage: nghttp [OPTIONS]... <URI>...\n"
|
||||
<< "HTTP/2 experimental client" << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -1670,7 +1674,8 @@ void print_help(std::ostream& out)
|
|||
{
|
||||
print_usage(out);
|
||||
out << "\n"
|
||||
<< "OPTIONS:\n"
|
||||
<< " <URI> Specify URI to access.\n"
|
||||
<< "Options:\n"
|
||||
<< " -v, --verbose Print debug information such as reception/\n"
|
||||
<< " transmission of frames and name/value pairs.\n"
|
||||
<< " -n, --null-out Discard downloaded data.\n"
|
||||
|
@ -1720,6 +1725,8 @@ void print_help(std::ostream& out)
|
|||
<< " padding. Specify 0 to disable padding.\n"
|
||||
<< " --color Force colored log output.\n"
|
||||
<< " --continuation Send large header to test CONTINUATION.\n"
|
||||
<< " --version Display version information and exit.\n"
|
||||
<< " -h, --help Display this help and exit.\n"
|
||||
<< std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -1751,6 +1758,7 @@ int main(int argc, char **argv)
|
|||
{"key", required_argument, &flag, 2},
|
||||
{"color", no_argument, &flag, 3},
|
||||
{"continuation", no_argument, &flag, 4},
|
||||
{"version", no_argument, &flag, 5},
|
||||
{nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
int option_index = 0;
|
||||
|
@ -1889,6 +1897,10 @@ int main(int argc, char **argv)
|
|||
// continuation option
|
||||
config.continuation = true;
|
||||
break;
|
||||
case 5:
|
||||
// version option
|
||||
print_version(std::cout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -72,12 +72,19 @@ int parse_push_config(Config& config, const char *optarg)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void print_version(std::ostream& out)
|
||||
{
|
||||
out << "nghttpd nghttp2/" NGHTTP2_VERSION << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void print_usage(std::ostream& out)
|
||||
{
|
||||
out << "Usage: nghttpd [-DVhpv] [-d <PATH>] [--no-tls] [-b <ALIGNMENT>]\n"
|
||||
<< " <PORT> [<PRIVATE_KEY> <CERT>]"
|
||||
<< std::endl;
|
||||
out << "Usage: nghttpd [OPTION]... <PORT> <PRIVATE_KEY> <CERT>\n"
|
||||
<< " or: nghttpd --no-tls [OPTION]... <PORT>\n"
|
||||
<< "HTTP/2 experimental server" << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -86,7 +93,13 @@ void print_help(std::ostream& out)
|
|||
{
|
||||
print_usage(out);
|
||||
out << "\n"
|
||||
<< "OPTIONS:\n"
|
||||
<< " <PORT> Specify listening port number.\n"
|
||||
<< " <PRIVATE_KEY> Set path to server's private key. Required\n"
|
||||
<< " unless --no-tls is specified.\n"
|
||||
<< " <CERT> Set path to server's certificate. Required\n"
|
||||
<< " unless --no-tls is specified.\n"
|
||||
<< "\n"
|
||||
<< "Options:\n"
|
||||
<< " -D, --daemon Run in a background. If -D is used, the\n"
|
||||
<< " current working directory is changed to '/'.\n"
|
||||
<< " Therefore if this option is used, -d option\n"
|
||||
|
@ -117,7 +130,8 @@ void print_help(std::ostream& out)
|
|||
<< " root. See --htdocs option.\n"
|
||||
<< " -b, --padding=<N> Add at most <N> bytes to a frame payload as\n"
|
||||
<< " padding. Specify 0 to disable padding.\n"
|
||||
<< " -h, --help Print this help.\n"
|
||||
<< " --version Display version information and exit.\n"
|
||||
<< " -h, --help Display this help and exit.\n"
|
||||
<< std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -139,6 +153,7 @@ int main(int argc, char **argv)
|
|||
{"padding", required_argument, nullptr, 'b'},
|
||||
{"no-tls", no_argument, &flag, 1},
|
||||
{"color", no_argument, &flag, 2},
|
||||
{"version", no_argument, &flag, 3},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
int option_index = 0;
|
||||
|
@ -192,6 +207,10 @@ int main(int argc, char **argv)
|
|||
// color option
|
||||
color = true;
|
||||
break;
|
||||
case 3:
|
||||
// version
|
||||
print_version(std::cout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
30
src/shrpx.cc
30
src/shrpx.cc
|
@ -462,12 +462,8 @@ void print_version(std::ostream& out)
|
|||
namespace {
|
||||
void print_usage(std::ostream& out)
|
||||
{
|
||||
out << "Usage: nghttpx [-Dh] [-s|--client|-p] [-b <HOST,PORT>]\n"
|
||||
<< " [-f <HOST,PORT>] [-n <CORES>] [-c <NUM>] [-L <LEVEL>]\n"
|
||||
<< " [OPTIONS...] [<PRIVATE_KEY> <CERT>]\n"
|
||||
<< "\n"
|
||||
<< "A reverse proxy for HTTP/2, HTTP/1 and SPDY.\n"
|
||||
<< std::endl;
|
||||
out << "Usage: nghttpx [OPTIONS]... [<PRIVATE_KEY> <CERT>]\n"
|
||||
<< "A reverse proxy for HTTP/2, HTTP/1 and SPDY." << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -475,17 +471,17 @@ namespace {
|
|||
void print_help(std::ostream& out)
|
||||
{
|
||||
print_usage(out);
|
||||
out << "Positional arguments:\n"
|
||||
out << "\n"
|
||||
<< " <PRIVATE_KEY> Set path to server's private key. Required\n"
|
||||
<< " unless -p, --client or --frontend-no-tls\n"
|
||||
<< " are given.\n"
|
||||
<< " <CERT> Set path to server's certificate. Required\n"
|
||||
<< " unless -p, --client or --frontend-no-tls\n"
|
||||
<< " are given.\n"
|
||||
<< "Options:\n"
|
||||
<< " The options are categorized into several groups.\n"
|
||||
<< "\n"
|
||||
<< "OPTIONS:\n"
|
||||
<< "\n"
|
||||
<< " Connections:\n"
|
||||
<< "Connections:\n"
|
||||
<< " -b, --backend=<HOST,PORT>\n"
|
||||
<< " Set backend host and port.\n"
|
||||
<< " Default: '"
|
||||
|
@ -504,7 +500,7 @@ void print_help(std::ostream& out)
|
|||
<< " --backend-ipv6 Resolve backend hostname to IPv6 address\n"
|
||||
<< " only.\n"
|
||||
<< "\n"
|
||||
<< " Performance:\n"
|
||||
<< "Performance:\n"
|
||||
<< " -n, --workers=<CORES>\n"
|
||||
<< " Set the number of worker threads.\n"
|
||||
<< " Default: "
|
||||
|
@ -533,7 +529,7 @@ void print_help(std::ostream& out)
|
|||
<< " Default: "
|
||||
<< get_config()->write_burst << "\n"
|
||||
<< "\n"
|
||||
<< " Timeout:\n"
|
||||
<< "Timeout:\n"
|
||||
<< " --frontend-http2-read-timeout=<SEC>\n"
|
||||
<< " Specify read timeout for HTTP/2.0 and SPDY frontend\n"
|
||||
<< " connection. Default: "
|
||||
|
@ -574,7 +570,7 @@ void print_help(std::ostream& out)
|
|||
<< " can be specified by --backend-read-timeout\n"
|
||||
<< " and --backend-write-timeout options.\n"
|
||||
<< "\n"
|
||||
<< " SSL/TLS:\n"
|
||||
<< "SSL/TLS:\n"
|
||||
<< " --ciphers=<SUITE> Set allowed cipher list. The format of the\n"
|
||||
<< " string is described in OpenSSL ciphers(1).\n"
|
||||
<< " If this option is used, --honor-cipher-order\n"
|
||||
|
@ -644,7 +640,7 @@ void print_help(std::ostream& out)
|
|||
<< " as a part of protocol string.\n"
|
||||
<< " Default: " << DEFAULT_TLS_PROTO_LIST << "\n"
|
||||
<< "\n"
|
||||
<< " HTTP/2.0 and SPDY:\n"
|
||||
<< "HTTP/2.0 and SPDY:\n"
|
||||
<< " -c, --http2-max-concurrent-streams=<NUM>\n"
|
||||
<< " Set the maximum number of the concurrent\n"
|
||||
<< " streams in one HTTP/2.0 and SPDY session.\n"
|
||||
|
@ -682,7 +678,7 @@ void print_help(std::ostream& out)
|
|||
<< " meant for debugging purpose and not intended\n"
|
||||
<< " to enhance protocol security.\n"
|
||||
<< "\n"
|
||||
<< " Mode:\n"
|
||||
<< "Mode:\n"
|
||||
<< " (default mode) Accept HTTP/2.0, SPDY and HTTP/1.1 over\n"
|
||||
<< " SSL/TLS. If --frontend-no-tls is used,\n"
|
||||
<< " accept HTTP/2.0 and HTTP/1.1. The incoming\n"
|
||||
|
@ -709,7 +705,7 @@ void print_help(std::ostream& out)
|
|||
<< " an absolute URI, suitable for use as a\n"
|
||||
<< " forward proxy.\n"
|
||||
<< "\n"
|
||||
<< " Logging:\n"
|
||||
<< "Logging:\n"
|
||||
<< " -L, --log-level=<LEVEL>\n"
|
||||
<< " Set the severity level of log output.\n"
|
||||
<< " INFO, WARNING, ERROR and FATAL.\n"
|
||||
|
@ -721,7 +717,7 @@ void print_help(std::ostream& out)
|
|||
<< " Default: "
|
||||
<< str_syslog_facility(get_config()->syslog_facility) << "\n"
|
||||
<< "\n"
|
||||
<< " Misc:\n"
|
||||
<< "Misc:\n"
|
||||
<< " --add-x-forwarded-for\n"
|
||||
<< " Append X-Forwarded-For header field to the\n"
|
||||
<< " downstream request.\n"
|
||||
|
|
Loading…
Reference in New Issue