nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit d754425bfaaaedc15faa98e3391af50682c82e31
parent 46e3e639f8efe35d2a878a5b1674235cead05abf
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Fri, 10 Dec 2021 18:40:33 +0100

Added batch mode

Diffstat:
Mdoc/nissy.1 | 27++++++++++++++++++---------
Mnissy | 0
Mnissy-2.0beta5.tar.gz | 0
Msrc/shell.c | 26+++++++++++++++++---------
Msrc/shell.h | 2+-
5 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/doc/nissy.1 b/doc/nissy.1 @@ -6,25 +6,34 @@ .Nd a Rubik's cube solver and FMC assistant . .Sh SYNOPSIS -.Nm +.Nm Op Fl b .Nm .Ar command .Op options... . -When run without any argument an interactive shell is launched, otherwise -the provided -.Ar command -is executed and nissy terminates. -The commands that can be run in the interactive shell are the same that can -be run non-interactively and are provided below. -. .Sh DESCRIPTION .Nm is a Rubik's Cube solver. Its optimal solver function uses Kociemba's one-step algorithm (huge optimal solver), and its performance is comparable to that -of Kociemba's implementation in Cube Explorer. +of Kociemba's implementation in Cube Explorer when using a single CPU +thread, and much faster when using multiple threads. nissy can also solve different substeps of the Thistlethwaite's algorithm and more. +.Pp +When run without any argument an interactive shell is launched, otherwise +the provided +.Ar command +is executed and nissy terminates. If the option +.Fl b +is given, every argument after it is ignored and the shell is launched without +any prompt or welcome message. This can be used to run nissy in batch mode, +for example writing a list of commands in a +.Ar file +(one per line) and running +.Ar nissy -b < file +.Pp +The commands that can be run in the interactive shell are the same that can +be run non-interactively and are provided below. . .Sh COMMANDS The available diff --git a/nissy b/nissy Binary files differ. diff --git a/nissy-2.0beta5.tar.gz b/nissy-2.0beta5.tar.gz Binary files differ. diff --git a/src/shell.c b/src/shell.c @@ -55,7 +55,7 @@ exec_args(int c, char **v) } void -launch() +launch(bool prompt) { int i, shell_argc; char line[MAXLINELEN], **shell_argv; @@ -64,12 +64,15 @@ launch() for (i = 0; i < MAXNTOKENS; i++) shell_argv[i] = malloc((MAXTOKENLEN+1) * sizeof(char)); - fprintf(stderr, "Welcome to Nissy "VERSION".\n" - "Type \"commands\" for a list of commands.\n" - ); + if (prompt) { + fprintf(stderr, "Welcome to Nissy "VERSION".\n" + "Type \"commands\" for a list of commands.\n"); + } while (true) { - fprintf(stdout, "nissy-# "); + if (prompt) { + fprintf(stdout, "nissy-# "); + } if (fgets(line, MAXLINELEN, stdin) == NULL) break; shell_argc = parseline(line, shell_argv); @@ -85,10 +88,15 @@ launch() int main(int argc, char *argv[]) { - if (argc > 1) - exec_args(argc-1, &argv[1]); - else - launch(); + if (argc > 1) { + if (!strcmp(argv[1], "-b")) { + launch(false); + } else { + exec_args(argc-1, &argv[1]); + } + } else { + launch(true); + } return 0; } diff --git a/src/shell.h b/src/shell.h @@ -8,6 +8,6 @@ #define MAXNTOKENS 255 void exec_args(int c, char **v); -void launch(); +void launch(bool prompt); #endif