mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Add --parse-only option to exit after parsing scripts.
May be useful for syntax-checking tools.
This commit is contained in:
parent
0f3ed1a553
commit
06b6dc8447
1 changed files with 11 additions and 1 deletions
12
src/main.cc
12
src/main.cc
|
@ -166,6 +166,7 @@ void usage()
|
||||||
fprintf(stderr, "bro version %s\n", bro_version());
|
fprintf(stderr, "bro version %s\n", bro_version());
|
||||||
fprintf(stderr, "usage: %s [options] [file ...]\n", prog);
|
fprintf(stderr, "usage: %s [options] [file ...]\n", prog);
|
||||||
fprintf(stderr, " <file> | policy file, or read stdin\n");
|
fprintf(stderr, " <file> | policy file, or read stdin\n");
|
||||||
|
fprintf(stderr, " -a|--parse-only | exit immediately after parsing scripts\n");
|
||||||
fprintf(stderr, " -b|--bare-mode | don't load scripts from the base/ directory\n");
|
fprintf(stderr, " -b|--bare-mode | don't load scripts from the base/ directory\n");
|
||||||
fprintf(stderr, " -d|--debug-policy | activate policy file debugging\n");
|
fprintf(stderr, " -d|--debug-policy | activate policy file debugging\n");
|
||||||
fprintf(stderr, " -e|--exec <bro code> | augment loaded policies by given code\n");
|
fprintf(stderr, " -e|--exec <bro code> | augment loaded policies by given code\n");
|
||||||
|
@ -454,6 +455,7 @@ int main(int argc, char** argv)
|
||||||
char* seed_save_file = 0;
|
char* seed_save_file = 0;
|
||||||
char* user_pcap_filter = 0;
|
char* user_pcap_filter = 0;
|
||||||
char* debug_streams = 0;
|
char* debug_streams = 0;
|
||||||
|
int parse_only = false;
|
||||||
int bare_mode = false;
|
int bare_mode = false;
|
||||||
int seed = 0;
|
int seed = 0;
|
||||||
int dump_cfg = false;
|
int dump_cfg = false;
|
||||||
|
@ -465,6 +467,7 @@ int main(int argc, char** argv)
|
||||||
int print_plugins = 0;
|
int print_plugins = 0;
|
||||||
|
|
||||||
static struct option long_opts[] = {
|
static struct option long_opts[] = {
|
||||||
|
{"parse-only", no_argument, 0, 'a'},
|
||||||
{"bare-mode", no_argument, 0, 'b'},
|
{"bare-mode", no_argument, 0, 'b'},
|
||||||
{"debug-policy", no_argument, 0, 'd'},
|
{"debug-policy", no_argument, 0, 'd'},
|
||||||
{"dump-config", no_argument, 0, 'g'},
|
{"dump-config", no_argument, 0, 'g'},
|
||||||
|
@ -544,7 +547,7 @@ int main(int argc, char** argv)
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
|
|
||||||
char opts[256];
|
char opts[256];
|
||||||
safe_strncpy(opts, "B:D:e:f:I:i:K:l:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLNOPSWbdghv",
|
safe_strncpy(opts, "B:D:e:f:I:i:K:l:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLNOPSWabdghv",
|
||||||
sizeof(opts));
|
sizeof(opts));
|
||||||
|
|
||||||
#ifdef USE_PERFTOOLS_DEBUG
|
#ifdef USE_PERFTOOLS_DEBUG
|
||||||
|
@ -554,6 +557,10 @@ int main(int argc, char** argv)
|
||||||
int op;
|
int op;
|
||||||
while ( (op = getopt_long(argc, argv, opts, long_opts, &long_optsind)) != EOF )
|
while ( (op = getopt_long(argc, argv, opts, long_opts, &long_optsind)) != EOF )
|
||||||
switch ( op ) {
|
switch ( op ) {
|
||||||
|
case 'a':
|
||||||
|
parse_only = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
bare_mode = true;
|
bare_mode = true;
|
||||||
break;
|
break;
|
||||||
|
@ -890,6 +897,9 @@ int main(int argc, char** argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( parse_only )
|
||||||
|
exit(reporter->Errors() > 0 ? 1 : 0);
|
||||||
|
|
||||||
#ifdef USE_PERFTOOLS_DEBUG
|
#ifdef USE_PERFTOOLS_DEBUG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue