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
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void print_version(std::ostream& out)
|
||||||
|
{
|
||||||
|
out << "nghttp nghttp2/" NGHTTP2_VERSION << std::endl;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << "Usage: nghttp [-Oansuv] [-t <SECONDS>] [-w <WINDOW_BITS>] [-W <WINDOW_BITS>]\n"
|
out << "Usage: nghttp [OPTIONS]... <URI>...\n"
|
||||||
<< " [--cert=<CERT>] [--key=<KEY>] [-d <FILE>] [-m <N>]\n"
|
<< "HTTP/2 experimental client" << std::endl;
|
||||||
<< " [-p <PRIORITY>] [-M <N>] [-b <ALIGNMENT>]\n"
|
|
||||||
<< " <URI>..."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -1670,7 +1674,8 @@ void print_help(std::ostream& out)
|
||||||
{
|
{
|
||||||
print_usage(out);
|
print_usage(out);
|
||||||
out << "\n"
|
out << "\n"
|
||||||
<< "OPTIONS:\n"
|
<< " <URI> Specify URI to access.\n"
|
||||||
|
<< "Options:\n"
|
||||||
<< " -v, --verbose Print debug information such as reception/\n"
|
<< " -v, --verbose Print debug information such as reception/\n"
|
||||||
<< " transmission of frames and name/value pairs.\n"
|
<< " transmission of frames and name/value pairs.\n"
|
||||||
<< " -n, --null-out Discard downloaded data.\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"
|
<< " padding. Specify 0 to disable padding.\n"
|
||||||
<< " --color Force colored log output.\n"
|
<< " --color Force colored log output.\n"
|
||||||
<< " --continuation Send large header to test CONTINUATION.\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;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -1751,6 +1758,7 @@ int main(int argc, char **argv)
|
||||||
{"key", required_argument, &flag, 2},
|
{"key", required_argument, &flag, 2},
|
||||||
{"color", no_argument, &flag, 3},
|
{"color", no_argument, &flag, 3},
|
||||||
{"continuation", no_argument, &flag, 4},
|
{"continuation", no_argument, &flag, 4},
|
||||||
|
{"version", no_argument, &flag, 5},
|
||||||
{nullptr, 0, nullptr, 0 }
|
{nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
@ -1889,6 +1897,10 @@ int main(int argc, char **argv)
|
||||||
// continuation option
|
// continuation option
|
||||||
config.continuation = true;
|
config.continuation = true;
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
// version option
|
||||||
|
print_version(std::cout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -72,12 +72,19 @@ int parse_push_config(Config& config, const char *optarg)
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void print_version(std::ostream& out)
|
||||||
|
{
|
||||||
|
out << "nghttpd nghttp2/" NGHTTP2_VERSION << std::endl;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << "Usage: nghttpd [-DVhpv] [-d <PATH>] [--no-tls] [-b <ALIGNMENT>]\n"
|
out << "Usage: nghttpd [OPTION]... <PORT> <PRIVATE_KEY> <CERT>\n"
|
||||||
<< " <PORT> [<PRIVATE_KEY> <CERT>]"
|
<< " or: nghttpd --no-tls [OPTION]... <PORT>\n"
|
||||||
<< std::endl;
|
<< "HTTP/2 experimental server" << std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -86,7 +93,13 @@ void print_help(std::ostream& out)
|
||||||
{
|
{
|
||||||
print_usage(out);
|
print_usage(out);
|
||||||
out << "\n"
|
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"
|
<< " -D, --daemon Run in a background. If -D is used, the\n"
|
||||||
<< " current working directory is changed to '/'.\n"
|
<< " current working directory is changed to '/'.\n"
|
||||||
<< " Therefore if this option is used, -d option\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"
|
<< " root. See --htdocs option.\n"
|
||||||
<< " -b, --padding=<N> Add at most <N> bytes to a frame payload as\n"
|
<< " -b, --padding=<N> Add at most <N> bytes to a frame payload as\n"
|
||||||
<< " padding. Specify 0 to disable padding.\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;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -139,6 +153,7 @@ int main(int argc, char **argv)
|
||||||
{"padding", required_argument, nullptr, 'b'},
|
{"padding", required_argument, nullptr, 'b'},
|
||||||
{"no-tls", no_argument, &flag, 1},
|
{"no-tls", no_argument, &flag, 1},
|
||||||
{"color", no_argument, &flag, 2},
|
{"color", no_argument, &flag, 2},
|
||||||
|
{"version", no_argument, &flag, 3},
|
||||||
{nullptr, 0, nullptr, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
@ -192,6 +207,10 @@ int main(int argc, char **argv)
|
||||||
// color option
|
// color option
|
||||||
color = true;
|
color = true;
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
// version
|
||||||
|
print_version(std::cout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
14
src/shrpx.cc
14
src/shrpx.cc
|
@ -462,12 +462,8 @@ void print_version(std::ostream& out)
|
||||||
namespace {
|
namespace {
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << "Usage: nghttpx [-Dh] [-s|--client|-p] [-b <HOST,PORT>]\n"
|
out << "Usage: nghttpx [OPTIONS]... [<PRIVATE_KEY> <CERT>]\n"
|
||||||
<< " [-f <HOST,PORT>] [-n <CORES>] [-c <NUM>] [-L <LEVEL>]\n"
|
<< "A reverse proxy for HTTP/2, HTTP/1 and SPDY." << std::endl;
|
||||||
<< " [OPTIONS...] [<PRIVATE_KEY> <CERT>]\n"
|
|
||||||
<< "\n"
|
|
||||||
<< "A reverse proxy for HTTP/2, HTTP/1 and SPDY.\n"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -475,15 +471,15 @@ namespace {
|
||||||
void print_help(std::ostream& out)
|
void print_help(std::ostream& out)
|
||||||
{
|
{
|
||||||
print_usage(out);
|
print_usage(out);
|
||||||
out << "Positional arguments:\n"
|
out << "\n"
|
||||||
<< " <PRIVATE_KEY> Set path to server's private key. Required\n"
|
<< " <PRIVATE_KEY> Set path to server's private key. Required\n"
|
||||||
<< " unless -p, --client or --frontend-no-tls\n"
|
<< " unless -p, --client or --frontend-no-tls\n"
|
||||||
<< " are given.\n"
|
<< " are given.\n"
|
||||||
<< " <CERT> Set path to server's certificate. Required\n"
|
<< " <CERT> Set path to server's certificate. Required\n"
|
||||||
<< " unless -p, --client or --frontend-no-tls\n"
|
<< " unless -p, --client or --frontend-no-tls\n"
|
||||||
<< " are given.\n"
|
<< " are given.\n"
|
||||||
<< "\n"
|
<< "Options:\n"
|
||||||
<< "OPTIONS:\n"
|
<< " The options are categorized into several groups.\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "Connections:\n"
|
<< "Connections:\n"
|
||||||
<< " -b, --backend=<HOST,PORT>\n"
|
<< " -b, --backend=<HOST,PORT>\n"
|
||||||
|
|
Loading…
Reference in New Issue