From f14fca5a656b3f60042e309d45657a1948c06f6d Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 13 Aug 2021 03:24:30 +1000 Subject: Actually use toybox option parsing, and combine last two name parts. --- src/sledjchisl/sledjchisl.c | 50 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 0aa0bf2..9bbc63b 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -2,16 +2,14 @@ * * Copyright 2020 David Seikel * Not in SUSv4. An entirely new invention, thus no web site either. - * - * Not using the usual taybox args system, coz it's not working as advertised. -USE_SLEDJCHISL(NEWTOY(sledjchisl, "qia", TOYFLAG_USR|TOYFLAG_BIN)) +USE_SLEDJCHISL(NEWTOY(sledjchisl, "?qma", TOYFLAG_USR|TOYFLAG_BIN)) config SLEDJCHISL bool "sledjchisl" default y help - usage: sledjchisl [-q] [-a] [mode [arguments]] + usage: sledjchisl [-qma] [mode [name]] opensim-SC management system. @@ -27,14 +25,15 @@ config SLEDJCHISL Will start a sim or everything. -q when starting everything wont show the tmux console. backup - backup -i - backup -i "Joan Smith" + backup -m + backup -m "Joan Smith" backup Welcome backup Welcome.ini backup Welcome.shini backup "Welcome sim" Will backup sim or everything. - gitar i "Joan Smith" + -m for a members inventory. + gitar m "Joan Smith" gitar Welcome gitar Welcome.ini gitar Welcome.shini @@ -62,6 +61,13 @@ config SLEDJCHISL */ +// Toybox's strend overrides another strend that causes MariaDB library to crash. Renaming it to tb_strend helps. +// I deal with that by using a sed invokation when building toybox. +#define FOR_sledjchisl +#include "toys.h" + +GLOBALS( +) /* configs/sim01 - @@ -137,10 +143,6 @@ extern char **environ; #include "openssl/hmac.h" #include -// Toybox's strend overrides another strend that causes MariaDB library to crash. Renaming it to tb_strend helps. -// I deal with that by using a sed invokation when building toybox. -#include "toys.h" - typedef enum { CREATE = 0, @@ -1806,7 +1808,7 @@ void doSimsThing(simData *simd, char *sim, char *type, int count, int window, in break; } - case BACKUP : // "backup -i 'onefang rejected'" "backup 'Welcome sim'" "backup Welcome.shini" "Welcome.shini backup" "backup Welcome.ini" "backup Welcome" "backup" backup everything + case BACKUP : // "backup -m 'onefang rejected'" "backup 'Welcome sim'" "backup Welcome.shini" "Welcome.shini backup" "backup Welcome.ini" "backup Welcome" "backup" backup everything { // TODO - If it's not a sim code, and not a sim name, it's an account inventory. if (checkSimIsRunning(simd->tab)) { @@ -1843,7 +1845,7 @@ void doSimsThing(simData *simd, char *sim, char *type, int count, int window, in break; } - case GITAR : // "gitAR i name" "gitAR o name" + case GITAR : // "gitAR -m avatar name" "gitAR sim name" { break; } @@ -7651,7 +7653,7 @@ jit library is loaded or the JIT compiler will not be activated. E("tmux select-pane command failed!"); } // toybox argument parsing is half working. - if ((NULL == toys.optargs[0]) || (('-' != toys.optargs[0][0]) && ('q' != toys.optargs[0][1]))) + if (!FLAG(q)) { V("Joining the session."); // Join the session. @@ -7870,23 +7872,27 @@ jit library is loaded or the JIT compiler will not be activated. if (0 == toys.optc) ; - else if (strcmp(toys.optargs[0], "create") == 0) - currentMode = CREATE; - else if (strcmp(toys.optargs[0], "start") == 0) - currentMode = START; else if (strcmp(toys.optargs[0], "backup") == 0) currentMode = BACKUP; + else if (strcmp(toys.optargs[0], "create") == 0) + currentMode = CREATE; else if (strcmp(toys.optargs[0], "gitar") == 0) currentMode = GITAR; + else if (strcmp(toys.optargs[0], "restart") == 0) + currentMode = RESTART; + else if (strcmp(toys.optargs[0], "start") == 0) + currentMode = START; else if (strcmp(toys.optargs[0], "status") == 0) currentMode = STATUS; else if (strcmp(toys.optargs[0], "stop") == 0) currentMode = STOP; - else - ourSims->target = toys.optargs[0]; if (2 == toys.optc) - ourSims->target = toys.optargs[1]; -//V("ARGS - %d %d %i |%s| %s |%s|", toys.optc, toys.optflags, currentMode, toys.optargs[0], toys.optargs[1], ourSims->target); + ourSims->target = xstrdup(toys.optargs[1]); + else if (3 == toys.optc) + ourSims->target = xmprintf("%s %s", toys.optargs[1], toys.optargs[2]); + else + ourSims->target = NULL; +V("Doing %s for %s '%s' %s %s", modeStrings[currentMode], FLAG(m) ? "member" : "", ourSims->target, FLAG(q) ? "quiet" : "", FLAG(a) ? "all" : ""); // Start ROBUST or join the tmux session, or just figure out where the sims are running in tmux. if ((START == currentMode) && !checkSimIsRunning("ROBUST")) -- cgit v1.1