From 5ec04ab8c3a401ca0d73abe77a3e4d78f47eb1f6 Mon Sep 17 00:00:00 2001 From: Mark Atwood Date: Thu, 20 Sep 2007 12:13:16 -0700 Subject: [PATCH] add single letter command line options -V for --version -h for --help -v for --verbose -d for --debug -s for --servers --- src/client_options.h | 12 ++++++------ src/memcat.c | 8 ++++---- src/memcp.c | 9 ++++----- src/memrm.c | 8 ++++---- src/memstat.c | 8 ++++---- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/client_options.h b/src/client_options.h index 6dd43135..204135aa 100644 --- a/src/client_options.h +++ b/src/client_options.h @@ -1,10 +1,10 @@ typedef enum { - OPT_SERVERS= 1, - OPT_VERSION, - OPT_HELP, - OPT_VERBOSE, - OPT_DEBUG, - OPT_FLAG, + OPT_SERVERS= 's', + OPT_VERSION= 'V', + OPT_HELP= 'h', + OPT_VERBOSE= 'v', + OPT_DEBUG= 'd', + OPT_FLAG= 257, OPT_EXPIRE, OPT_SET, OPT_REPLACE, diff --git a/src/memcat.c b/src/memcat.c index 11b42d7d..0b9690b2 100644 --- a/src/memcat.c +++ b/src/memcat.c @@ -69,20 +69,20 @@ void options_parse(int argc, char *argv[]) while (1) { - option_rv = getopt_long(argc, argv, "", long_options, &option_index); + option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; - case OPT_VERSION: /* --version */ + case OPT_VERSION: /* --version or -V */ printf("memcache tools, memcat, v1.0\n"); exit(0); break; - case OPT_HELP: /* --help */ + case OPT_HELP: /* --help or -h */ printf("useful help messages go here\n"); exit(0); break; - case OPT_SERVERS: /* --servers */ + case OPT_SERVERS: /* --servers or -s */ opt_servers= optarg; break; case '?': diff --git a/src/memcp.c b/src/memcp.c index 88cbc351..90d3fb37 100644 --- a/src/memcp.c +++ b/src/memcp.c @@ -102,21 +102,20 @@ void options_parse(int argc, char *argv[]) while (1) { - option_rv= getopt_long(argc, argv, "", long_options, &option_index); + option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: - if (long_options[option_index].name) break; - case OPT_VERSION: /* --version */ + case OPT_VERSION: /* --version or -V */ printf("memcache tools, memcp, v1.0\n"); exit(0); - case OPT_HELP: /* --help */ + case OPT_HELP: /* --help or -h */ printf("useful help messages go here\n"); exit(0); - case OPT_SERVERS: /* --servers */ + case OPT_SERVERS: /* --servers or -s */ opt_servers= optarg; break; case OPT_FLAG: /* --flag */ diff --git a/src/memrm.c b/src/memrm.c index b297379f..5b6474b0 100644 --- a/src/memrm.c +++ b/src/memrm.c @@ -30,20 +30,20 @@ int main(int argc, char *argv[]) while (1) { - option_rv = getopt_long(argc, argv, "", long_options, &option_index); + option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; - case OPT_VERSION: /* --version */ + case OPT_VERSION: /* --version or -V */ printf("memcache tools, memrm, v1.0\n"); exit(0); break; - case OPT_HELP: /* --help */ + case OPT_HELP: /* --help or -h */ printf("useful help messages go here\n"); exit(0); break; - case OPT_SERVERS: /* --servers */ + case OPT_SERVERS: /* --servers or -s */ opt_servers = optarg; break; case OPT_EXPIRE: /* --expire */ diff --git a/src/memstat.c b/src/memstat.c index 76fdd9c6..dcfb3af9 100644 --- a/src/memstat.c +++ b/src/memstat.c @@ -50,20 +50,20 @@ void options_parse(int argc, char *argv[]) while (1) { - option_rv = getopt_long(argc, argv, "", long_options, &option_index); + option_rv = getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; - case OPT_VERSION: /* --version */ + case OPT_VERSION: /* --version or -V */ printf("memcache tools, memcat, v1.0\n"); exit(0); break; - case OPT_HELP: /* --help */ + case OPT_HELP: /* --help or -h */ printf("useful help messages go here\n"); exit(0); break; - case OPT_SERVERS: /* --servers */ + case OPT_SERVERS: /* --servers or -s */ opt_servers = optarg; break; case '?': -- 2.30.2