From: Plom Heller Date: Thu, 30 Jul 2026 01:35:16 +0000 (+0200) Subject: Add "?" choice for -m/-s to list sorters/matchers available to chosen table. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/test.html?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=bricksplom Add "?" choice for -m/-s to list sorters/matchers available to chosen table. --- diff --git a/bricksplom.py b/bricksplom.py index acbe7b7..7098deb 100755 --- a/bricksplom.py +++ b/bricksplom.py @@ -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}')