aboutsummaryrefslogtreecommitdiffstats
path: root/src/s6/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s6/service.c')
-rw-r--r--src/s6/service.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/s6/service.c b/src/s6/service.c
new file mode 100644
index 0000000..5ac453b
--- /dev/null
+++ b/src/s6/service.c
@@ -0,0 +1,28 @@
+/* ISC license. */
+
+#include <skalibs/prog.h>
+#include <skalibs/strerr.h>
+
+#include "s6-internal.h"
+
+#define USAGE "s6 service [ service options ] subcommand [ subcommand options ] services... Type \"s6 service help\" for details."
+#define dieusage() strerr_dieusage(100, USAGE)
+
+static struct command_s const service_commands[] =
+{
+ { .s = "help", .f = &service_help },
+ { .s = "start", .f = &service_start },
+ { .s = "status", .f = &service_status },
+ { .s = "stop", .f = &service_stop },
+} ;
+
+int service (char const *const *argv)
+{
+ struct command_s *cmd ;
+
+ PROG = "s6 service" ;
+ if (!*argv) dieusage() ;
+ cmd = BSEARCH(struct command_s, *argv, service_commands) ;
+ if (!cmd) dieusage() ;
+ return (*cmd->f)(++argv) ;
+}