aboutsummaryrefslogtreecommitdiff
path: root/src/rc/_usage.h
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2011-02-12 19:15:29 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2011-02-14 18:40:05 -0600
commit73d1a8698e101b1dcf589b27b35ac9b09ea6d02c (patch)
treec1ab7cbb6370d43c20f87ca0480f18731ecc0ed1 /src/rc/_usage.h
parentbae0a693a9271b3ed0f723fdafc22efe5f07b70e (diff)
make version option common
This reworks the code for the version option so that it is part of the parser loop and is a common option to all applets.
Diffstat (limited to 'src/rc/_usage.h')
-rw-r--r--src/rc/_usage.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index d65e05e7..5e116c94 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
* All rights reserved
-
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,11 +24,12 @@
* SUCH DAMAGE.
*/
-#define getoptstring_COMMON "Chqv"
+#define getoptstring_COMMON "ChqVv"
#define longopts_COMMON \
{ "help", 0, NULL, 'h'}, \
{ "nocolor", 0, NULL, 'C'}, \
+ { "version", 0, NULL, 'V'}, \
{ "verbose", 0, NULL, 'v'}, \
{ "quiet", 0, NULL, 'q'}, \
{ NULL, 0, NULL, 0 }
@@ -36,11 +37,13 @@
#define longopts_help_COMMON \
"Display this help output", \
"Disable color output", \
+ "Display software version", \
"Run verbosely", \
"Run quietly"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
+#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
#define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
#define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1);
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
@@ -48,6 +51,7 @@
#define case_RC_COMMON_GETOPT \
case 'C': case_RC_COMMON_getopt_case_C; break; \
case 'h': case_RC_COMMON_getopt_case_h; break; \
+ case 'V': case_RC_COMMON_getopt_case_V; break; \
case 'v': case_RC_COMMON_getopt_case_v; break; \
case 'q': case_RC_COMMON_getopt_case_q; break; \
default: case_RC_COMMON_getopt_default; break;