aboutsummaryrefslogtreecommitdiffstats
path: root/src/s6/s6.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s6/s6.c')
-rw-r--r--src/s6/s6.c27
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() ;