From 3f75ffee7c0c7d6b70cf305d60435ac862ea9ab5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 6 Jun 2025 13:48:20 +0000 Subject: Implement "s6 process" Signed-off-by: Laurent Bercot --- src/s6/s6.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/s6/s6.c') diff --git a/src/s6/s6.c b/src/s6/s6.c index b9bc61f..c7d950c 100644 --- a/src/s6/s6.c +++ b/src/s6/s6.c @@ -14,7 +14,7 @@ #include #include "s6-internal.h" -#define USAGE "s6 [ generic options ] subcommand [ command options ] command_arguments... Type \"s6 help\" for details." +#define USAGE "s6 [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details." #define dieusage() strerr_dieusage(100, USAGE) enum main_golb_e @@ -30,6 +30,7 @@ enum main_gola_e MAIN_GOLA_LIVEDIR, MAIN_GOLA_REPODIR, MAIN_GOLA_VERBOSITY, + MAIN_GOLA_COLOR, MAIN_GOLA_N } ; @@ -44,7 +45,8 @@ static gol_arg const main_gola[MAIN_GOLA_N] = { .so = 's', .lo = "scandir", .i = MAIN_GOLA_SCANDIR }, { .so = 'l', .lo = "livedir", .i = MAIN_GOLA_LIVEDIR }, { .so = 'r', .lo = "repodir", .i = MAIN_GOLA_REPODIR }, - { .so = 'v', .lo = "verbosity", .i = MAIN_GOLA_VERBOSITY } + { .so = 'v', .lo = "verbosity", .i = MAIN_GOLA_VERBOSITY }, + { .so = 0, .lo = "color", .i = MAIN_GOLA_COLOR } } ; struct global_s *g ; @@ -52,6 +54,7 @@ struct global_s *g ; static struct command_s const main_commands[] = { { .s = "help", .f = &help }, + { .s = "process", .f = &process }, { .s = "version", .f = &version }, } ; @@ -79,6 +82,26 @@ int main (int argc, char const *const *argv, char const *const *envp) if (gola[MAIN_GOLA_LIVEDIR]) strerr_warni("livedir is ", gola[MAIN_GOLA_LIVEDIR]) ; if (gola[MAIN_GOLA_REPODIR]) strerr_warni("repodir is ", gola[MAIN_GOLA_REPODIR]) ; + { + int force_color = 0 ; + if (gola[MAIN_GOLA_COLOR]) + { + if (!strcmp(gola[MAIN_GOLA_COLOR], "yes")) + { + force_color = 1 ; + g->color = 1 ; + } + else if (!strcmp(gola[MAIN_GOLA_COLOR], "no")) + { + force_color = 1 ; + g->color = 0 ; + } + else if (strcmp(gola[MAIN_GOLA_COLOR], "auto")) + strerr_dief1x(100, "--color value must be yes, no, or auto") ; + } + if (!force_color) g->color = isatty(1) ; + } + if (!*argv) dieusage() ; cmd = BSEARCH(struct command_s, *argv, main_commands) ; if (!cmd) dieusage() ; -- cgit v1.3.1