mirror of
https://github.com/troglobit/finit.git
synced 2026-11-17 19:30:29 +00:00
initctl: add '-n, --numeric' mode to prefer JOB:ID over NAME:ID
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
815454c065
commit
e8561b7f90
1 file changed
+18
-12
+18
-12
@@ -49,6 +49,7 @@ struct command {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int heading = 1;
|
int heading = 1;
|
||||||
|
int numeric = 0;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int runlevel = 0;
|
int runlevel = 0;
|
||||||
|
|
||||||
@@ -284,7 +285,12 @@ static int do_cond_show(char *arg)
|
|||||||
|
|
||||||
cond = cond_get_agg(svc->cond);
|
cond = cond_get_agg(svc->cond);
|
||||||
|
|
||||||
printf("%-*d %-*s ", pw, svc->pid, iw, svc_ident(svc, ident, sizeof(ident)));
|
if (!numeric)
|
||||||
|
svc_ident(svc, ident, sizeof(ident));
|
||||||
|
else
|
||||||
|
svc_jobid(svc, ident, sizeof(ident));
|
||||||
|
|
||||||
|
printf("%-*d %-*s ", pw, svc->pid, iw, ident);
|
||||||
|
|
||||||
if (cond == COND_ON)
|
if (cond == COND_ON)
|
||||||
printf("%-6.6s ", condstr(cond));
|
printf("%-6.6s ", condstr(cond));
|
||||||
@@ -427,11 +433,6 @@ char *runlevel_string(int runlevel, int levels)
|
|||||||
return lvl;
|
return lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* In verbose mode we skip the header and each service description.
|
|
||||||
* This in favor of having all info on one line so a machine can more
|
|
||||||
* easily parse it.
|
|
||||||
*/
|
|
||||||
static int show_status(char *arg)
|
static int show_status(char *arg)
|
||||||
{
|
{
|
||||||
char ident[MAX_IDENT_LEN];
|
char ident[MAX_IDENT_LEN];
|
||||||
@@ -481,12 +482,12 @@ static int show_status(char *arg)
|
|||||||
|
|
||||||
printf("%-*d ", pw, svc->pid);
|
printf("%-*d ", pw, svc->pid);
|
||||||
|
|
||||||
if (!verbose)
|
if (!numeric)
|
||||||
printf("%-*s ", iw, svc_ident(svc, ident, sizeof(ident)));
|
svc_ident(svc, ident, sizeof(ident));
|
||||||
else
|
else
|
||||||
printf("%-*s ", iw, svc_jobid(svc, ident, sizeof(ident)));
|
svc_jobid(svc, ident, sizeof(ident));
|
||||||
|
|
||||||
printf("%-8s ", svc_status(svc));
|
printf("%-*s %-8s ", iw, ident, svc_status(svc));
|
||||||
|
|
||||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||||
if (strchr(lvls, '\e'))
|
if (strchr(lvls, '\e'))
|
||||||
@@ -583,6 +584,7 @@ static int usage(int rc)
|
|||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -b, --batch Batch mode, no screen size probing\n"
|
" -b, --batch Batch mode, no screen size probing\n"
|
||||||
|
" -n, --numeric Show JOB:ID instead of NAME:ID\n"
|
||||||
" -t, --no-heading Skip table headings\n"
|
" -t, --no-heading Skip table headings\n"
|
||||||
" -v, --verbose Verbose output\n"
|
" -v, --verbose Verbose output\n"
|
||||||
" -h, --help This help text\n"
|
" -h, --help This help text\n"
|
||||||
@@ -665,13 +667,14 @@ int main(int argc, char *argv[])
|
|||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{ "batch", 0, NULL, 'b' },
|
{ "batch", 0, NULL, 'b' },
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
|
{ "numeric", 0, NULL, 'n' },
|
||||||
{ "no-heading", 0, NULL, 't' },
|
{ "no-heading", 0, NULL, 't' },
|
||||||
{ "verbose", 0, NULL, 'v' },
|
{ "verbose", 0, NULL, 'v' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
progname(argv[0]);
|
progname(argv[0]);
|
||||||
while ((c = getopt_long(argc, argv, "bh?tv", long_options, NULL)) != EOF) {
|
while ((c = getopt_long(argc, argv, "bh?ntv", long_options, NULL)) != EOF) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
@@ -681,6 +684,10 @@ int main(int argc, char *argv[])
|
|||||||
case '?':
|
case '?':
|
||||||
return usage(0);
|
return usage(0);
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
numeric = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
heading = 0;
|
heading = 0;
|
||||||
break;
|
break;
|
||||||
@@ -727,7 +734,6 @@ void logit(int prio, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
|
|||||||
Reference in new issue
Block a user