home · contact · privacy
Add "?" choice for -m/-s to list sorters/matchers available to chosen table. master
authorPlom Heller <plom@plomlompom.com>
Thu, 30 Jul 2026 01:35:16 +0000 (03:35 +0200)
committerPlom Heller <plom@plomlompom.com>
Thu, 30 Jul 2026 01:35:16 +0000 (03:35 +0200)
bricksplom.py

index acbe7b7fcc8d6bfc3d523f3ae9cd5403fbbdf9e0..7098deb8085e3af98cadaa56b803e43478579a39 100755 (executable)
@@ -803,6 +803,10 @@ class BricksDb:
         assert table_name in self.lookupables
         assert (not show_raw) or table_name in self.textfiled_tables()
         cls = self.lookupables[table_name]
+        if match_by == '?':
+            return CHAR_NEWLINE.join(cls.matchers().keys())
+        if sort_by == '?':
+            return CHAR_NEWLINE.join(cls.sorters().keys())
         table = getattr(self, table_name)
         if item_id:
             match_by = PARAM_Q_ID + item_id
@@ -847,20 +851,21 @@ def main(
                    choices=choices, type=complete, metavar='TABLE', help=msg)
         parser = ArgumentParser()
         add_abbreviable_table_arg()
+        hint_sortmatch = 'use "?" to see what be available for chosen table'
+        hint_raw = ('only available for tables: '
+                    + ', '.join(BricksDb.textfiled_tables().keys()))
         parser.add_argument(
                 'item_id',
                 nargs='?', metavar='ITEM_ID')
         parser.add_argument(
                 '-m', '--match-by',
-                action='store')
+                action='store', help=hint_sortmatch)
         parser.add_argument(
                 '-s', '--sort-by',
-                action='store', default=TOK_SORT_ID)
+                action='store', help=hint_sortmatch, default=TOK_SORT_ID)
         parser.add_argument(
                 '-l', '--ldraw',
                 action='store', default='')
-        hint_raw = ('only available for tables: '
-                    + ', '.join(BricksDb.textfiled_tables().keys()))
         action_raw = parser.add_argument(
                 '-r', '--raw',
                 action='store_true', help=f'NB: {hint_raw}')