mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
notcurses-demo: accept -i to continue on demo failure
This commit is contained in:
parent
dfe4a99446
commit
05997f9988
@ -9,7 +9,7 @@ notcurses-demo - Show off some notcurses features
|
||||
# SYNOPSIS
|
||||
|
||||
**notcurses-demo** [**-h|--help**] [**-p path**] [**-d delaymult**]
|
||||
[**-l loglevel**] [**-kHVc**] demospec
|
||||
[**-l loglevel**] [**-f renderfile**] [**-ikHVc**] demospec
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@ -48,12 +48,16 @@ At any time, press 'q' to quit. The demo is best run in at least a 80x45 termina
|
||||
|
||||
**-l loglevel**: Log everything (high log level) or nothing (log level 0) to stderr.
|
||||
|
||||
**-f renderfile**: Render each frame to **renderfile** in addition to the screen.
|
||||
|
||||
**-H**: Launch a HUD with running timers for each demo. This HUD can be moved or closed with the mouse.
|
||||
|
||||
**-k**: Inhibit use of the alternate screen. Necessary if you want the output left on your terminal after the program exits.
|
||||
|
||||
**-c**: Do not attempt to seed the PRNG. This is useful when benchmarking.
|
||||
|
||||
**-i**: Continue after a failing demo.
|
||||
|
||||
**-h**: Print a usage message, and exit with success.
|
||||
|
||||
**-V**: Print the program name and version, and exit with success.
|
||||
|
@ -149,7 +149,7 @@ usage(const char* exe, int status){
|
||||
}
|
||||
|
||||
static demoresult*
|
||||
ext_demos(struct notcurses* nc, const char* spec){
|
||||
ext_demos(struct notcurses* nc, const char* spec, bool ignore_failures){
|
||||
int ret = 0;
|
||||
results = malloc(sizeof(*results) * strlen(spec));
|
||||
if(results == NULL){
|
||||
@ -176,7 +176,7 @@ ext_demos(struct notcurses* nc, const char* spec){
|
||||
results[i].timens = nowns - prevns;
|
||||
prevns = nowns;
|
||||
results[i].result = ret;
|
||||
if(ret){
|
||||
if(!ignore_failures){
|
||||
break;
|
||||
}
|
||||
hud_completion_notify(&results[i]);
|
||||
@ -188,14 +188,15 @@ ext_demos(struct notcurses* nc, const char* spec){
|
||||
// specification, also returns NULL, heh. determine this by argv[optind];
|
||||
// if it's NULL, there were valid options, but no spec.
|
||||
static const char*
|
||||
handle_opts(int argc, char** argv, notcurses_options* opts, bool* use_hud){
|
||||
handle_opts(int argc, char** argv, notcurses_options* opts, bool* use_hud,
|
||||
bool* ignore_failures){
|
||||
strcpy(datadir, NOTCURSES_SHARE);
|
||||
char renderfile[PATH_MAX] = "";
|
||||
bool constant_seed = false;
|
||||
int c;
|
||||
*use_hud = false;
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
while((c = getopt(argc, argv, "HVhckl:r:d:f:p:")) != EOF){
|
||||
while((c = getopt(argc, argv, "HVhickl:r:d:f:p:")) != EOF){
|
||||
switch(c){
|
||||
case 'H':
|
||||
*use_hud = true;
|
||||
@ -221,6 +222,9 @@ handle_opts(int argc, char** argv, notcurses_options* opts, bool* use_hud){
|
||||
case 'c':
|
||||
constant_seed = true;
|
||||
break;
|
||||
case 'i':
|
||||
*ignore_failures = true;
|
||||
break;
|
||||
case 'k':
|
||||
opts->inhibit_alternate_screen = true;
|
||||
break;
|
||||
@ -393,9 +397,9 @@ int main(int argc, char** argv){
|
||||
sigaddset(&sigmask, SIGWINCH);
|
||||
pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
|
||||
notcurses_options nopts;
|
||||
bool use_hud;
|
||||
const char* spec;
|
||||
if((spec = handle_opts(argc, argv, &nopts, &use_hud)) == NULL){
|
||||
bool use_hud, ignore_failures;
|
||||
if((spec = handle_opts(argc, argv, &nopts, &use_hud, &ignore_failures)) == NULL){
|
||||
if(argv[optind] != NULL){
|
||||
usage(*argv, EXIT_FAILURE);
|
||||
}
|
||||
@ -437,7 +441,7 @@ int main(int argc, char** argv){
|
||||
nanosleep(&demodelay, NULL);
|
||||
}
|
||||
}
|
||||
if(ext_demos(nc, spec) == NULL){
|
||||
if(ext_demos(nc, spec, ignore_failures) == NULL){
|
||||
goto err;
|
||||
}
|
||||
if(hud_destroy()){
|
||||
|
Loading…
Reference in New Issue
Block a user