Commit fa0f8b40 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add -h option to print usage and exit

parent 075e6e64
......@@ -53,14 +53,14 @@
static const char progname[] = "varnishlog";
static void
usage(void)
usage(int status)
{
const char **opt;
fprintf(stderr, "Usage: %s <options>\n\n", progname);
fprintf(stderr, "Options:\n");
for (opt = vopt_usage; *opt != NULL; opt += 2)
fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1));
exit(1);
exit(status);
}
int
......@@ -72,14 +72,16 @@ main(int argc, char * const *argv)
while ((opt = getopt(argc, argv, vopt_optstring)) != -1) {
switch (opt) {
case 'h':
usage(0);
default:
if (!VUT_Arg(opt, optarg))
usage();
usage(1);
}
}
if (optind != argc)
usage();
usage(1);
VUT_Setup();
VUT_Main(NULL, NULL);
......
......@@ -37,6 +37,7 @@ VSL_OPT_C
VUT_OPT_d
VUT_OPT_D
VUT_OPT_g
VUT_OPT_h
VSL_OPT_i
VSL_OPT_I
VSL_OPT_L
......
......@@ -52,6 +52,11 @@
" by request." \
)
#define VUT_OPT_h \
VOPT("h", "[-h]", "Usage help", \
"Print program usage and exit" \
)
#define VUT_OPT_n \
VOPT("n:", "[-n name]", "Varnish instance name", \
"Specify the name of the varnishd instance to get logs" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment