From: Toru Maesaka Date: Fri, 16 Jan 2009 10:05:07 +0000 (+0900) Subject: Print help with startup error to save people from re-executing with --help X-Git-Tag: 0.26~19 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=d333fb781926d527fbe43553c1bc7351c2205312;p=awesomized%2Flibmemcached Print help with startup error to save people from re-executing with --help --- diff --git a/clients/memstat.c b/clients/memstat.c index 36ee343e..8c1bbea0 100644 --- a/clients/memstat.c +++ b/clients/memstat.c @@ -22,6 +22,17 @@ static int opt_verbose= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; +static struct option long_options[]= +{ + {"version", no_argument, NULL, OPT_VERSION}, + {"help", no_argument, NULL, OPT_HELP}, + {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, + {"debug", no_argument, &opt_verbose, OPT_DEBUG}, + {"servers", required_argument, NULL, OPT_SERVERS}, + {"flag", no_argument, &opt_displayflag, OPT_FLAG}, + {0, 0, 0, 0}, +}; + int main(int argc, char *argv[]) { unsigned int x; @@ -41,7 +52,8 @@ int main(int argc, char *argv[]) opt_servers= strdup(temp); else { - fprintf(stderr, "No Servers provided\n"); + fprintf(stderr, "No Servers provided\n\n"); + help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, 0); exit(1); } } @@ -101,17 +113,6 @@ void options_parse(int argc, char *argv[]) {0}, }; - static struct option long_options[]= - { - {"version", no_argument, NULL, OPT_VERSION}, - {"help", no_argument, NULL, OPT_HELP}, - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, - {"servers", required_argument, NULL, OPT_SERVERS}, - {"flag", no_argument, &opt_displayflag, OPT_FLAG}, - {0, 0, 0, 0}, - }; - int option_index= 0; int option_rv;