home · contact · privacy
Add check-only mode with TABLE=CHECK.
authorPlom Heller <plom@plomlompom.com>
Mon, 10 Aug 2026 22:25:41 +0000 (00:25 +0200)
committerPlom Heller <plom@plomlompom.com>
Mon, 10 Aug 2026 22:25:41 +0000 (00:25 +0200)
src/run.py

index ce8fe2a5fc582438584145ed4501a0d40c4f821f..0e66d53f1eb46dd09c4b1f9003074d0aa20f6438 100755 (executable)
@@ -23,6 +23,7 @@ from bricksplom.misc import (
 NAME_ENV_DIRNAME = 'BRICKSPLOM_DIR'
 NAME_ENV_LDRAW = 'LDRAW_DIR'
 NAME_ENV_CONFIG = 'BRICKSPLON_CONFIG'
+ARG_CHECK = 'CHECK'
 
 
 def main(
@@ -41,8 +42,9 @@ def main(
                         action,
                         f'{arg} – ambiguous, matches: {", ".join(candidates)}')
                 return (candidates + (arg, ))[0]
-            choices = BricksDb.lookupables.keys()
+            choices = tuple(BricksDb.lookupables.keys()) + (ARG_CHECK,)
             msg = 'one of: ' + ', '.join(sorted(list(choices)))
+            msg += f' (use "{ARG_CHECK}" to only run consistency checks)'
             msg += '; NB: abbreviable to first unambiguous character sequence'
             action = parser.add_argument(
                    'table',
@@ -87,13 +89,14 @@ def main(
     path_tables = environ.get(NAME_ENV_DIRNAME, config.get('path_tables', ''))
     path_ldraw = environ.get(NAME_ENV_LDRAW, config.get('path_ldraw', ''))
     db = BricksDb(path_tables, path_ldraw, args.ldraw)
-    print(
-        db.lookup(
-            table_name=args.table,
-            formatter=args.format,
-            match_by=args.match,
-            sort_by=args.sort
-        ).rstrip())
+    if not args.table == ARG_CHECK:
+        print(
+            db.lookup(
+                table_name=args.table,
+                formatter=args.format,
+                match_by=args.match,
+                sort_by=args.sort
+            ).rstrip())
 
 
 if __name__ == '__main__':