2007-06-28 21:14:38 +05:30
|
|
|
/*
|
|
|
|
* @file _usage.h
|
|
|
|
* @brief standardize help/usage output across all our programs
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* Copyright 2007 Gentoo Foundation
|
|
|
|
* Released under the GPLv2
|
|
|
|
*/
|
|
|
|
|
2007-09-26 13:22:48 +05:30
|
|
|
#define getoptstring_COMMON "Chqv"
|
2007-09-25 21:51:38 +05:30
|
|
|
|
2007-06-28 21:14:38 +05:30
|
|
|
#define longopts_COMMON \
|
|
|
|
{ "help", 0, NULL, 'h'}, \
|
2007-09-19 21:57:37 +05:30
|
|
|
{ "nocolor", 0, NULL, 'C'}, \
|
2007-09-26 04:47:25 +05:30
|
|
|
{ "verbose", 0, NULL, 'v'}, \
|
2007-10-09 23:11:53 +05:30
|
|
|
{ "quiet", 0, NULL, 'q'}, \
|
|
|
|
{ NULL, 0, NULL, 0 }
|
2007-09-25 21:51:38 +05:30
|
|
|
|
|
|
|
#define longopts_help_COMMON \
|
|
|
|
"Display this help output (duh)", \
|
|
|
|
"Disable color output", \
|
2007-09-26 04:47:25 +05:30
|
|
|
"Run verbosely", \
|
2007-09-25 21:51:38 +05:30
|
|
|
"Run quietly"
|
2007-06-28 21:14:38 +05:30
|
|
|
|
2007-09-26 04:47:25 +05:30
|
|
|
#define case_RC_COMMON_getopt_case_C setenv ("RC_NOCOLOR", "yes", 1);
|
|
|
|
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
|
|
|
|
#define case_RC_COMMON_getopt_case_v setenv ("RC_VERBOSE", "yes", 1);
|
|
|
|
#define case_RC_COMMON_getopt_case_q setenv ("RC_QUIET", "yes", 1);
|
|
|
|
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
|
|
|
|
|
2007-06-28 21:14:38 +05:30
|
|
|
#define case_RC_COMMON_GETOPT \
|
2007-09-26 04:47:25 +05:30
|
|
|
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 'q': case_RC_COMMON_getopt_case_q; break; \
|
|
|
|
default: case_RC_COMMON_getopt_default; break;
|