common C code: add "-t" option for test mode.

This commit is contained in:
2023-03-22 08:43:46 +01:00
parent f490c2353e
commit a214d2b70d
2 changed files with 13 additions and 3 deletions

View File

@@ -13,5 +13,5 @@
#define _AOC_H_
extern int parseargs(int ac, char**av);
extern int testmode(void);
#endif /* _AOC_H_ */

View File

@@ -17,18 +17,28 @@
#include "aoc.h"
#include "debug.h"
static int _testmode = 0;
static int usage(char *prg)
{
fprintf(stderr, "Usage: %s [-d debug_level] [-p part] [-i input]\n", prg);
fprintf(stderr, "Usage: %s [-t][-d debug_level] [-p part] [-i input]\n", prg);
return 1;
}
int testmode(void)
{
return _testmode;
}
int parseargs(int ac, char **av)
{
int opt, part = 1;
while ((opt = getopt(ac, av, "d:p:")) != -1) {
while ((opt = getopt(ac, av, "td:p:")) != -1) {
switch (opt) {
case 't':
_testmode = 1;
break;
case 'd':
debug_level_set(atoi(optarg));
break;