diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-06-06 13:48:20 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-06-06 13:48:20 +0000 |
| commit | 3f75ffee7c0c7d6b70cf305d60435ac862ea9ab5 (patch) | |
| tree | 45d86cdc414e6534305d2b723666c1291d74b940 /src/s6/s6.c | |
| parent | 73988ba1cfa375582c86302116192fb8ec567f48 (diff) | |
| download | s6-frontend-3f75ffee7c0c7d6b70cf305d60435ac862ea9ab5.tar.gz | |
Implement "s6 process"
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/s6/s6.c')
| -rw-r--r-- | src/s6/s6.c | 27 |
1 files changed, 25 insertions, 2 deletions
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 <s6-frontend/config.h> #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() ; |
