1111)
1212from azul .args import (
1313 AzulArgumentHelpFormatter ,
14+ Origin ,
1415)
1516from azul .azulclient import (
1617 AzulClient ,
5758parser .add_argument ('--catalogs' ,
5859 nargs = '+' ,
5960 metavar = 'NAME' ,
60- default = [
61- catalog .name
62- for catalog in config .catalogs .values ()
63- if not catalog .is_integration_test_catalog
64- ]
65- if config .current_catalog is None else
66- [
67- config .catalogs [config .current_catalog ].name
68- ],
6961 choices = config .catalogs ,
7062 help = 'The names of the catalogs to reindex.' )
7163parser .add_argument ('--sources' ,
72- default = config .current_sources ,
7364 nargs = '+' ,
7465 help = 'Limit reindexing to a subset of the configured sources. '
7566 'Supports shell-style wildcards to match multiple sources per argument. '
@@ -128,7 +119,29 @@ def main(argv: list[str]):
128119
129120 azul = AzulClient (num_workers = args .num_workers )
130121
131- source_globs = set (args .sources )
122+ if args .catalog is None :
123+ catalog_origin = 'environment variable'
124+ if config .current_catalog is None :
125+ catalogs = [
126+ catalog .name
127+ for catalog in config .catalogs .values ()
128+ if not catalog .is_integration_test_catalog
129+ ]
130+ else :
131+ catalogs = [config .catalogs [config .current_catalog ].name ]
132+ else :
133+ catalog_origin = 'command line argument'
134+ catalogs = args .catalogs
135+ log .info ('Using catalog(s) specified via %s: %r' , catalog_origin , catalogs )
136+
137+ if len (args .sources ) == 0 :
138+ source_origin = 'environment variable'
139+ source_globs = set (config .current_sources )
140+ else :
141+ source_origin = 'command line argument'
142+ source_globs = set (args .sources )
143+ log .info ('Using source glob(s) specified via %s: %r' , source_origin , source_globs )
144+
132145 every_source = '*' in source_globs
133146 deindex = args .deindex or (args .delete and not every_source )
134147 delete = args .delete and every_source
@@ -146,15 +159,15 @@ def main(argv: list[str]):
146159 parser .error ('--deindex is incompatible with --create and --delete.' )
147160 assert False
148161
149- sources_by_catalog = azul .matching_sources (args . catalogs , source_globs )
162+ sources_by_catalog = azul .matching_sources (catalogs , source_globs )
150163 azul .require_no_failures_before ()
151164
152165 if deindex :
153166 for catalog , sources in sources_by_catalog .items ():
154167 if sources :
155168 azul .deindex (catalog , sources )
156169
157- azul .reset_indexer (args . catalogs ,
170+ azul .reset_indexer (catalogs ,
158171 purge_queues = args .purge ,
159172 delete_indices = delete ,
160173 create_indices = args .create or args .index and delete )
@@ -182,7 +195,7 @@ def main(argv: list[str]):
182195 if args .wait :
183196 if num_notifications == 0 :
184197 log .warning ('No notifications for prefix %r and catalogs %r were sent' ,
185- args .prefix , args . catalogs )
198+ args .prefix , catalogs )
186199 else :
187200 azul .wait_for_indexer ()
188201 azul .require_no_failures_after ()
0 commit comments