Commit 7e52814c authored by Vivien Kraus's avatar Vivien Kraus

Introduce a batch mode for tarot

parent dc878588
Pipeline #96962 passed with stages
in 4 minutes
......@@ -1942,16 +1942,23 @@ them, since tarot is mainly an interactive program.
include = "int tarot_run ();";
main = {
main-type = main;
main-text = "res = tarot_run ();";
main-type = main;
main-text = "res = tarot_run ();";
};
flag = {
name = brief;
value = b;
descrip = "Do not print the greeting";
disable = not;
doc = 'Do not print the greeting when starting the program.';
name = brief;
descrip = "Do not print the greeting";
disable = not;
doc = 'Do not print the greeting when starting the program.';
};
flag = {
name = batch;
value = b;
descrip = "Do not display the user interface";
disable = not;
doc = "Do not display the user interface. Prompt commands from the standard input.";
};
#+END_SRC
......@@ -1999,7 +2006,7 @@ add_history (const char *line)
#include "tarot-opts.h"
int application_execute (int brief, int *exit_status);
int application_execute (int brief, int batch, int *exit_status);
int application_command (TarotCli * cli);
/* *INDENT-OFF* */
......@@ -2010,8 +2017,9 @@ int
tarot_run ()
{
int brief = HAVE_OPT (BRIEF) && ENABLED_OPT (BRIEF);
int batch = HAVE_OPT (BATCH) && ENABLED_OPT (BATCH);
int exit_status = 0;
if (application_execute (brief, &exit_status) == 0)
if (application_execute (brief, batch, &exit_status) == 0)
{
return exit_status;
}
......@@ -2044,7 +2052,7 @@ Of course, we need some vala code to actually do the job.
<<print-score>>
<<print-remaining-cards>>
<<print-hints>>
public static bool execute (bool brief, out int exit_status) {
public static bool execute (bool brief, bool batch, out int exit_status) {
exit_status = 0;
current_game = new Tarot.Game.alloc ();
current_counter = new Tarot.Counter.alloc ();
......@@ -2052,6 +2060,11 @@ Of course, we need some vala code to actually do the job.
if (!brief) {
print_user_greeting ();
}
#if WITH_GTK
if (!batch) {
return Tarot.Gui.try_run (brief, out exit_status);
}
#endif
return true;
}
private static string read_whole_file (GLib.FileStream file) {
......
......@@ -2,7 +2,7 @@
ACTUAL_FILE=$(mktemp)
./pre-inst-env tarot --brief < $1 2>&1 \
./pre-inst-env tarot --brief --batch < $1 2>&1 \
| grep -v "^> " \
| grep -v "^\\. " > $ACTUAL_FILE || exit 1
diff -q $ACTUAL_FILE $1.expected \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment