aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-23 09:19:48 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-23 09:28:02 +0200
commit95d8ddd7134e454feaee1d41623cc839eaede661 (patch)
tree126c7e563e458b55332df0582344386af8eaaa68 /cmd
parentc3249ae0c9777e8d16c90ce1ca441e90ad4fcf7b (diff)
Clean up service list short listing format
We already print the services in dependency order, for each target individually. There is no need to print the depencies and the target for each service. In addtion, printing name and description in one line shortens the resulting list. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/service/list.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/cmd/service/list.c b/cmd/service/list.c
index ad4cf00..6ba22f0 100644
--- a/cmd/service/list.c
+++ b/cmd/service/list.c
@@ -19,39 +19,16 @@
#include "service.h"
#include "config.h"
-static void print_services(service_t *svc)
+static void print_services(service_t *svc, const char *target)
{
- const char *ptr;
- int i;
+ printf("Services for target '%s' in dependency order:\n\n", target);
for (; svc != NULL; svc = svc->next) {
- printf("Name: %s\n", svc->name);
- printf("\tDescrption: %s\n", svc->desc);
+ printf("%s - %s\n", svc->name, svc->desc);
printf("\tType: %s\n", svc_type_to_string(svc->type));
- printf("\tTarget: %s\n", svc_target_to_string(svc->target));
if (svc->type == SVC_RESPAWN && svc->rspwn_limit > 0)
printf("\tRespawn limit: %d\n", svc->rspwn_limit);
-
- ptr = svc->before;
- if (ptr != NULL && svc->num_before > 0) {
- fputs("\tMust be run before:\n", stdout);
-
- for (i = 0; i < svc->num_before; ++i) {
- printf("\t\t%s\n", ptr);
- ptr += strlen(ptr) + 1;
- }
- }
-
- ptr = svc->after;
- if (ptr != NULL && svc->num_after > 0) {
- fputs("\tMust be run after:\n", stdout);
-
- for (i = 0; i < svc->num_after; ++i) {
- printf("\t\t%s\n", ptr);
- ptr += strlen(ptr) + 1;
- }
- }
}
}
@@ -79,10 +56,14 @@ static int cmd_list(int argc, char **argv)
goto out;
}
- print_services(list.targets[i]);
+ print_services(list.targets[i], argv[1]);
} else {
- for (i = 0; i < TGT_MAX; ++i)
- print_services(list.targets[i]);
+ for (i = 0; i < TGT_MAX; ++i) {
+ if (i != 0)
+ printf("\n\n");
+ print_services(list.targets[i],
+ svc_target_to_string(i));
+ }
}
out:
del_svc_list(&list);