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:
|
||||
|
|
14
src/shrpx.cc
14
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,15 +471,15 @@ 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"
|
||||
<< "\n"
|
||||
<< "OPTIONS:\n"
|
||||
<< "Options:\n"
|
||||
<< " The options are categorized into several groups.\n"
|
||||
<< "\n"
|
||||
<< "Connections:\n"
|
||||
<< " -b, --backend=<HOST,PORT>\n"
|
||||
|
|
Loading…
Reference in New Issue