Add support for describing the options in the C programs.

This commit is contained in:
Mike Frysinger
2007-09-25 16:21:38 +00:00
parent 17f430c0b9
commit 284286004e
12 changed files with 99 additions and 7 deletions

View File

@@ -5,6 +5,8 @@
Skip consolefont setup when RC_TTY_NUMBER is set to 0. Skip consolefont setup when RC_TTY_NUMBER is set to 0.
Add support for describing the options in the C programs.
24 Sep 2007; Mike Frysinger <vapier@gentoo.org>: 24 Sep 2007; Mike Frysinger <vapier@gentoo.org>:
Do not require portmap in netmount when nolock option is used with nfs Do not require portmap in netmount when nolock option is used with nfs

View File

@@ -16,7 +16,8 @@ static void usage (int exit_status)
#endif #endif
printf ("\n\nOptions: [" getoptstring "]\n"); printf ("\n\nOptions: [" getoptstring "]\n");
for (i = 0; longopts[i].name; ++i) for (i = 0; longopts[i].name; ++i)
printf (" -%c, --%s\n", longopts[i].val, longopts[i].name); printf (" -%c, --%-15s %s\n", longopts[i].val, longopts[i].name,
longopts_help[i]);
exit (exit_status); exit (exit_status);
} }

View File

@@ -8,11 +8,17 @@
*/ */
#define getoptstring_COMMON "Chq" #define getoptstring_COMMON "Chq"
#define longopts_COMMON \ #define longopts_COMMON \
{ "help", 0, NULL, 'h'}, \ { "help", 0, NULL, 'h'}, \
{ "nocolor", 0, NULL, 'C'}, \ { "nocolor", 0, NULL, 'C'}, \
{ "quiet", 0, NULL, 'q'}, { "quiet", 0, NULL, 'q'},
#define longopts_help_COMMON \
"Display this help output (duh)", \
"Disable color output", \
"Run quietly"
#define case_RC_COMMON_GETOPT \ #define case_RC_COMMON_GETOPT \
case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; \ case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; \
case 'h': usage (EXIT_SUCCESS); \ case 'h': usage (EXIT_SUCCESS); \

View File

@@ -143,6 +143,14 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"",
"",
"",
"",
"",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int checkown (int argc, char **argv) int checkown (int argc, char **argv)

View File

@@ -81,6 +81,11 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"Fork ldconfig into the background",
"Skip execution of ldconfig",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int env_update (int argc, char **argv) int env_update (int argc, char **argv)

View File

@@ -67,6 +67,13 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"Construct the arguments to give to mount",
"Extract the options field",
"Extract the pass number field",
"Extract the file system type",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int fstabinfo (int argc, char **argv) int fstabinfo (int argc, char **argv)

View File

@@ -263,6 +263,20 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int mountinfo (int argc, char **argv) int mountinfo (int argc, char **argv)

View File

@@ -65,6 +65,13 @@ static const struct option longopts[] = {
longopts_COMMON longopts_COMMON
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"Show services from all run levels",
"Show list of run levels",
"Show service list",
"Show services not assigned to any run level",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int rc_status (int argc, char **argv) int rc_status (int argc, char **argv)

View File

@@ -113,6 +113,13 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"Add the init.d to runlevels",
"Delete init.d from runlevels",
"Show init.d's in runlevels",
"Be verbose!",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
#define DOADD (1 << 0) #define DOADD (1 << 0)

View File

@@ -715,6 +715,9 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int main (int argc, char **argv) int main (int argc, char **argv)

View File

@@ -982,6 +982,14 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"",
"",
"",
"",
"",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int runscript (int argc, char **argv) int runscript (int argc, char **argv)

View File

@@ -487,6 +487,30 @@ static struct option longopts[] = {
longopts_COMMON longopts_COMMON
{ NULL, 0, NULL, 0} { NULL, 0, NULL, 0}
}; };
static const char * const longopts_help[] = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
longopts_help_COMMON
};
#include "_usage.c" #include "_usage.c"
int start_stop_daemon (int argc, char **argv) int start_stop_daemon (int argc, char **argv)