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.
Add support for describing the options in the C programs.
24 Sep 2007; Mike Frysinger <vapier@gentoo.org>:
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
printf ("\n\nOptions: [" getoptstring "]\n");
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);
}

View File

@ -8,10 +8,16 @@
*/
#define getoptstring_COMMON "Chq"
#define longopts_COMMON \
{ "help", 0, NULL, 'h'}, \
{ "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 \
case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; \

View File

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

View File

@ -65,7 +65,7 @@ static const char *colon_separated[] = {
NULL
};
static const char *space_separated[] = {
static const char *space_separated[] = {
"CONFIG_PROTECT",
"CONFIG_PROTECT_MASK",
NULL,
@ -81,6 +81,11 @@ static struct option longopts[] = {
longopts_COMMON
{ 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"
int env_update (int argc, char **argv)
@ -103,7 +108,7 @@ int env_update (int argc, char **argv)
bool ldconfig = true;
bool fork_ldconfig = false;
int nents = 0;
applet = argv[0];
while ((opt = getopt_long (argc, argv, getoptstring,

View File

@ -67,6 +67,13 @@ static struct option longopts[] = {
longopts_COMMON
{ 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"
int fstabinfo (int argc, char **argv)

View File

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

View File

@ -65,6 +65,13 @@ static const struct option longopts[] = {
longopts_COMMON
{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"
int rc_status (int argc, char **argv)

View File

@ -113,9 +113,16 @@ static struct option longopts[] = {
longopts_COMMON
{ 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"
#define DOADD (1 << 0)
#define DOADD (1 << 0)
#define DODELETE (1 << 1)
#define DOSHOW (1 << 2)

View File

@ -710,11 +710,14 @@ static void run_script (const char *script) {
}
#include "_usage.h"
#define getoptstring getoptstring_COMMON
#define getoptstring getoptstring_COMMON
static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
static const char * const longopts_help[] = {
longopts_help_COMMON
};
#include "_usage.c"
int main (int argc, char **argv)

View File

@ -972,7 +972,7 @@ static void svc_restart (bool deps)
}
#include "_usage.h"
#define getoptstring "dDqsv" getoptstring_COMMON
#define getoptstring "dDqsv" getoptstring_COMMON
static struct option longopts[] = {
{ "debug", 0, NULL, 'd'},
{ "ifstarted", 0, NULL, 's'},
@ -982,6 +982,14 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
static const char * const longopts_help[] = {
"",
"",
"",
"",
"",
longopts_help_COMMON
};
#include "_usage.c"
int runscript (int argc, char **argv)

View File

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