@@ -64,6 +64,9 @@ def fetch(query: c.BaseTemplate):
64
64
else :
65
65
if template_file :
66
66
logger (__name__ ).debug (f'Template file exists but is not a valid template: { template_file } ' )
67
+ else :
68
+ logger (__name__ ).error (f'Template not found: { query .name } ' )
69
+ return - 1
67
70
template = c .Conductor ().resolve_template (query , allow_offline = False )
68
71
logger (__name__ ).debug (f'Template from resolved query: { template } ' )
69
72
if template is None :
@@ -91,7 +94,7 @@ def fetch(query: c.BaseTemplate):
91
94
help = "Force apply the template, disregarding if the template is already installed." )
92
95
@click .option ('--remove-empty-dirs/--no-remove-empty-dirs' , 'remove_empty_directories' , is_flag = True , default = True ,
93
96
help = 'Remove empty directories when removing files' )
94
- @click .option ('--early-access/--disable -early-access' , '--early/--disable -early' , '-ea/-dea ' , 'early_access' , '--beta/--disable -beta' , default = None ,
97
+ @click .option ('--early-access/--no -early-access' , '--early/--no -early' , '-ea/-nea ' , 'early_access' , '--beta/--no -beta' , default = None ,
95
98
help = 'Create a project using the PROS 4 kernel' )
96
99
@project_option ()
97
100
@template_query (required = True )
@@ -142,7 +145,7 @@ def install(ctx: click.Context, **kwargs):
142
145
help = "Force apply the template, disregarding if the template is already installed." )
143
146
@click .option ('--remove-empty-dirs/--no-remove-empty-dirs' , 'remove_empty_directories' , is_flag = True , default = True ,
144
147
help = 'Remove empty directories when removing files' )
145
- @click .option ('--early-access/--disable -early-access' , '--early/--disable -early' , '-ea/-dea ' , 'early_access' , '--beta/--disable -beta' , default = None ,
148
+ @click .option ('--early-access/--no -early-access' , '--early/--no -early' , '-ea/-nea ' , 'early_access' , '--beta/--no -beta' , default = None ,
146
149
help = 'Create a project using the PROS 4 kernel' )
147
150
@project_option ()
148
151
@template_query (required = False )
@@ -156,7 +159,7 @@ def upgrade(ctx: click.Context, project: c.Project, query: c.BaseTemplate, **kwa
156
159
"""
157
160
analytics .send ("upgrade-project" )
158
161
if not query .name :
159
- for template in project .templates .keys ():
162
+ for template in tuple ( project .templates .keys () ):
160
163
click .secho (f'Upgrading { template } ' , color = 'yellow' )
161
164
q = c .BaseTemplate .create_query (name = template , target = project .target ,
162
165
supported_kernels = project .templates ['kernel' ].version )
@@ -204,7 +207,7 @@ def uninstall_template(project: c.Project, query: c.BaseTemplate, remove_user: b
204
207
help = 'Compile the project after creation' )
205
208
@click .option ('--build-cache' , is_flag = True , default = None , show_default = False ,
206
209
help = 'Build compile commands cache after creation. Overrides --compile-after if both are specified.' )
207
- @click .option ('--early-access/--disable -early-access' , '--early/--disable -early' , '-ea/-dea ' , 'early_access' , '--beta/--disable -beta' , default = None ,
210
+ @click .option ('--early-access/--no -early-access' , '--early/--no -early' , '-ea/-nea ' , 'early_access' , '--beta/--no -beta' , default = None ,
208
211
help = 'Create a project using the PROS 4 kernel' )
209
212
@click .pass_context
210
213
@default_options
@@ -248,7 +251,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
248
251
249
252
250
253
@conductor .command ('query-templates' ,
251
- aliases = ['search-templates' , 'ls-templates' , 'lstemplates' , 'querytemplates' , 'searchtemplates' ],
254
+ aliases = ['search-templates' , 'ls-templates' , 'lstemplates' , 'querytemplates' , 'searchtemplates' , 'q' ],
252
255
context_settings = {'ignore_unknown_options' : True })
253
256
@click .option ('--allow-offline/--no-offline' , 'allow_offline' , default = True , show_default = True ,
254
257
help = '(Dis)allow offline templates in the listing' )
@@ -258,12 +261,13 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
258
261
help = 'Force update all remote depots, ignoring automatic update checks' )
259
262
@click .option ('--limit' , type = int , default = 15 ,
260
263
help = 'The maximum number of displayed results for each library' )
261
- @click .option ('--early-access/--disable -early-access' , '--early/--disable -early' , '-ea/-dea ' , 'early_access' , '--beta/--disable -beta' , default = None ,
264
+ @click .option ('--early-access/--no -early-access' , '--early/--no -early' , '-ea/-nea ' , 'early_access' , '--beta/--no -beta' , default = None ,
262
265
help = 'View a list of early access templates' )
263
266
@template_query (required = False )
267
+ @project_option (required = False )
264
268
@click .pass_context
265
269
@default_options
266
- def query_templates (ctx , query : c .BaseTemplate , allow_offline : bool , allow_online : bool , force_refresh : bool ,
270
+ def query_templates (ctx , project : Optional [ c . Project ], query : c .BaseTemplate , allow_offline : bool , allow_online : bool , force_refresh : bool ,
267
271
limit : int , early_access : bool ):
268
272
"""
269
273
Query local and remote templates based on a spec
@@ -273,12 +277,10 @@ def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_onlin
273
277
analytics .send ("query-templates" )
274
278
if limit < 0 :
275
279
limit = 15
280
+ if early_access is None and project is not None :
281
+ early_access = project .use_early_access
276
282
templates = c .Conductor ().resolve_templates (query , allow_offline = allow_offline , allow_online = allow_online ,
277
283
force_refresh = force_refresh , early_access = early_access )
278
- if early_access :
279
- templates += c .Conductor ().resolve_templates (query , allow_offline = allow_offline , allow_online = allow_online ,
280
- force_refresh = force_refresh , early_access = False )
281
-
282
284
render_templates = {}
283
285
for template in templates :
284
286
key = (template .identifier , template .origin )
@@ -368,4 +370,26 @@ def query_depots(url: bool):
368
370
_conductor = c .Conductor ()
369
371
ui .echo (f"Available Depots{ ' (Add --url for the url)' if not url else '' } :\n " )
370
372
ui .echo ('\n ' .join (_conductor .query_depots (url ))+ "\n " )
371
-
373
+
374
+ @conductor .command ('reset' )
375
+ @click .option ('--force' , is_flag = True , default = False , help = 'Force reset' )
376
+ @default_options
377
+ def reset (force : bool ):
378
+ """
379
+ Reset conductor.pros
380
+
381
+ Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
382
+ """
383
+
384
+ if not force :
385
+ if not ui .confirm ("This will remove all depots and templates. You will be unable to create a new PROS project if you do not have internet connection. Are you sure you want to continue?" ):
386
+ ui .echo ("Aborting" )
387
+ return
388
+
389
+ # Delete conductor.pros
390
+ file = os .path .join (click .get_app_dir ('PROS' ), 'conductor.pros' )
391
+ if os .path .exists (file ):
392
+ os .remove (file )
393
+
394
+ ui .echo ("Conductor was reset" )
395
+
0 commit comments