]> git.gag.com Git - hw/altusmetrum/commitdiff
Add --warn-only flag to partslist-vendor
authorKeith Packard <keithp@keithp.com>
Wed, 12 Feb 2025 05:42:24 +0000 (21:42 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 12 Feb 2025 05:42:24 +0000 (21:42 -0800)
Signed-off-by: Keith Packard <keithp@keithp.com>
bin/partslist-vendor

index 19f4d55b9284c26b94208458c5cc4158f9c5247b..5a19926ad3a10349d60d18df5f424581e6934aac 100755 (executable)
@@ -17,6 +17,7 @@ file  output = stdout;
 int    argi;
 int    lineno = 0;
 bool   saw_error = false;
+bool   warn_only = false;
 
 void fatal(string format, poly args ...)
 {
@@ -27,7 +28,8 @@ void fatal(string format, poly args ...)
 void error(string format, poly args ...)
 {
        File::fprintf(stderr, format, args...);
-       saw_error = true;
+       if (!warn_only)
+               saw_error = true;
 }
 
 string[*] read_line(file f) {
@@ -203,7 +205,7 @@ void process_jlcpcb(string[string] entry)
                return;
        }
        string part_number;
-       if (hash_test(entry, "jlcpcb_part_number")) {
+       if (hash_test(entry, "jlcpcb_part_number") && entry["jlcpcb_part_number"] != "unknown") {
                part_number = entry["jlcpcb_part_number"];
        } else {
                error("Component (%s, %s, %s) has no JLCPCB Part #\n",
@@ -302,6 +304,10 @@ ParseArgs::argdesc argd = {
                  .abbr = 'm',
                  .name = "mfg",
                  .desc = "Display manufacturer part number"},
+               { .var = { .arg_flag = &warn_only },
+                 .abbr = 'w',
+                 .name = "warn-only",
+                 .desc = "Missing values are warnings rather than errors"},
                { .var = { .arg_string = &vendor_list },
                  .abbr = 'v',
                  .name = "vendor",