mirror of
https://github.com/troglobit/finit.git
synced 2026-11-30 21:18:22 +00:00
initctl: add '-t' switch to hide table headings
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
a226c93539
commit
99d22a7c21
1 file changed
+19
-8
+19
-8
@@ -48,6 +48,7 @@ struct command {
|
|||||||
int (*cb)(char *arg);
|
int (*cb)(char *arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int heading = 1;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int runlevel = 0;
|
int runlevel = 0;
|
||||||
|
|
||||||
@@ -220,7 +221,8 @@ static int dump_one_cond(const char *fpath, const struct stat *sb, int tflag, st
|
|||||||
|
|
||||||
static int do_cond_dump(char *arg)
|
static int do_cond_dump(char *arg)
|
||||||
{
|
{
|
||||||
printheader(NULL, "CONDITION STATUS", 0);
|
if (heading)
|
||||||
|
printheader(NULL, "CONDITION STATUS", 0);
|
||||||
|
|
||||||
if (nftw(_PATH_COND, dump_one_cond, 20, 0) == -1) {
|
if (nftw(_PATH_COND, dump_one_cond, 20, 0) == -1) {
|
||||||
warnx("Failed parsing %s", _PATH_COND);
|
warnx("Failed parsing %s", _PATH_COND);
|
||||||
@@ -235,7 +237,8 @@ static int do_cond_show(char *arg)
|
|||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
enum cond_state cond;
|
enum cond_state cond;
|
||||||
|
|
||||||
printheader(NULL, "PID SERVICE STATUS CONDITION (+ ON, ~ FLUX, - OFF)", 0);
|
if (heading)
|
||||||
|
printheader(NULL, "PID SERVICE STATUS CONDITION (+ ON, ~ FLUX, - OFF)", 0);
|
||||||
|
|
||||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||||
if (!svc->cond[0])
|
if (!svc->cond[0])
|
||||||
@@ -300,7 +303,8 @@ int utmp_show(char *file)
|
|||||||
int pid;
|
int pid;
|
||||||
char id[sizeof(ut->ut_id) + 1], user[sizeof(ut->ut_user) + 1], when[80];
|
char id[sizeof(ut->ut_id) + 1], user[sizeof(ut->ut_user) + 1], when[80];
|
||||||
|
|
||||||
printheader(NULL, file, 0);
|
if (heading)
|
||||||
|
printheader(NULL, file, 0);
|
||||||
utmpname(file);
|
utmpname(file);
|
||||||
|
|
||||||
setutent();
|
setutent();
|
||||||
@@ -418,10 +422,12 @@ static int show_status(char *arg)
|
|||||||
return do_log(svc->cmd);
|
return do_log(svc->cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!verbose)
|
if (heading) {
|
||||||
printheader(NULL, "IDENT STATUS PID RUNLEVELS DESCRIPTION", 0);
|
if (!verbose)
|
||||||
else
|
printheader(NULL, "IDENT STATUS PID RUNLEVELS DESCRIPTION", 0);
|
||||||
printheader(NULL, "IDENT STATUS PID RUNLEVELS COMMAND", 0);
|
else
|
||||||
|
printheader(NULL, "IDENT STATUS PID RUNLEVELS COMMAND", 0);
|
||||||
|
}
|
||||||
|
|
||||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||||
char *lvls;
|
char *lvls;
|
||||||
@@ -529,6 +535,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"
|
||||||
|
" -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"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -616,7 +623,7 @@ int main(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
progname(argv[0]);
|
progname(argv[0]);
|
||||||
while ((c = getopt_long(argc, argv, "bh?v", long_options, NULL)) != EOF) {
|
while ((c = getopt_long(argc, argv, "bh?tv", long_options, NULL)) != EOF) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
@@ -626,6 +633,10 @@ int main(int argc, char *argv[])
|
|||||||
case '?':
|
case '?':
|
||||||
return usage(0);
|
return usage(0);
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
heading = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user