diff --git a/b2/boom.c b/b2/boom.c index 96c74e5..ecaeb74 100644 --- a/b2/boom.c +++ b/b2/boom.c @@ -83,6 +83,22 @@ static void dump_hierarchy(struct action act) } +static void dump(const char *s) +{ + while (*s) { + switch (*s) { + case 'h': + dump_hierarchy(hierarchy); + break; + default: + fprintf(stderr, "no database '%c'\n", *s); + exit(1); + } + s++; + } +} + + static void usage(const char *name) { fprintf(stderr, @@ -97,6 +113,7 @@ static void usage(const char *name) " -X symbols (BOM supplement)\n" " other options:\n" " -v ... increase verbosity level\n" +" -dCHARS dump the specified database (h, c, i, ...)\n" " -N name for the next file, override the name in diagnostics\n" " -q var=value ... run substitutions with the specified inputs\n" " -Q var=value ... run substitutions and then do parametric search\n" @@ -116,33 +133,40 @@ int main(int argc, char **argv) if (!strcmp(argv[i], "-N")) { i++; file_name_override = argv[i]; - } else if (!strcmp(argv[i], "-v")) + } else if (!strcmp(argv[i], "-v")) { verbose++; - else if (!strcmp(argv[i], "-c")) + } else if (!strncmp(argv[i], "-d", 2)) { + if (argv[i][2]) { + dump(argv[i]+2); + } else { + i++; + if (!argv[i]) + usage(*argv); + dump(argv[i]); + } + } else if (!strcmp(argv[i], "-c")) { process = parse_characteristics; - else if (!strcmp(argv[i], "-i")) + } else if (!strcmp(argv[i], "-i")) { process = parse_inventory; - else if (!strcmp(argv[i], "-x")) + } else if (!strcmp(argv[i], "-x")) { process = parse_currencies; - else if (!strcmp(argv[i], "-p")) + } else if (!strcmp(argv[i], "-p")) { process = parse_providers; - else if (!strcmp(argv[i], "-s")) + } else if (!strcmp(argv[i], "-s")) { process = parse_substitutions; - else if (!strcmp(argv[i], "-b")) + } else if (!strcmp(argv[i], "-b")) { process = parse_kicad_bom; - else if (!strcmp(argv[i], "-X")) + } else if (!strcmp(argv[i], "-X")) { process = parse_symbols; - else if (!strcmp(argv[i], "-q")) + } else if (!strcmp(argv[i], "-q")) { process = add_var; - else if (!strcmp(argv[i], "-Q")) { + } else if (!strcmp(argv[i], "-Q")) { process = add_var; select_parts = 1; } else usage(*argv); } else { process(argv[i]); - if (verbose && process == parse_hierarchy) - dump_hierarchy(hierarchy); } } if (vars) diff --git a/b2/test/Common b/b2/test/Common index de6ecc0..5e7c4e3 100755 --- a/b2/test/Common +++ b/b2/test/Common @@ -20,7 +20,7 @@ run_boom() args="$args -$n <(sed -n '1,/^!-$n/d;/^!-/q;p' _in)" fi done - eval $VALGRIND ../boom -v "$args" "$@" + eval $VALGRIND ../boom "$args" "$@" } diff --git a/b2/test/hierfld b/b2/test/hierfld index b40a32f..347eba5 100755 --- a/b2/test/hierfld +++ b/b2/test/hierfld @@ -9,7 +9,7 @@ ############################################################################### -tst "hierarchy: name field" < = A }; EOF @@ -41,7 +41,7 @@ EOF #------------------------------------------------------------------------------ -tst "hierarchy: absolute value field (with unit)" < 1" < 1" -dh <1: { Y=* }; @@ -118,7 +118,7 @@ EOF #------------------------------------------------------------------------------ -tst "hierarchy: < 3 followed by predictable but reachable > 2" < 2" -dh <2: { Y=* }; diff --git a/b2/test/hierrul b/b2/test/hierrul index cb90932..ae592ed 100755 --- a/b2/test/hierrul +++ b/b2/test/hierrul @@ -9,7 +9,7 @@ ############################################################################### -tst "hierarchy: name rule" < = mouse { mouse: { X=* }; @@ -59,7 +59,7 @@ EOF #------------------------------------------------------------------------------ -tst "hierarchy: name set rule (duplicate entry)" < = mouse { mouse: { X=* }; @@ -79,7 +79,7 @@ EOF #------------------------------------------------------------------------------ -tst "hierarchy: absolute value rule (with unit)" < = mouse = mouse