7
7
from pros .conductor .templates import ExternalTemplate
8
8
from pros .ga .analytics import analytics
9
9
10
+
10
11
@pros_root
11
12
def conductor_cli ():
12
13
pass
@@ -90,8 +91,8 @@ def fetch(query: c.BaseTemplate):
90
91
help = "Force apply the template, disregarding if the template is already installed." )
91
92
@click .option ('--remove-empty-dirs/--no-remove-empty-dirs' , 'remove_empty_directories' , is_flag = True , default = True ,
92
93
help = 'Remove empty directories when removing files' )
93
- @click .option ('--beta ' , is_flag = True , default = False , show_default = True ,
94
- help = 'Allow applying beta templates ' )
94
+ @click .option ('--early-access/--disable-early-access ' , '--early/--disable-early' , '-ea/-dea' , 'early_access' , '--beta/--disable-beta' , default = None ,
95
+ help = 'Create a project using the PROS 4 kernel ' )
95
96
@project_option ()
96
97
@template_query (required = True )
97
98
@default_options
@@ -116,8 +117,6 @@ def apply(project: c.Project, query: c.BaseTemplate, **kwargs):
116
117
help = "Force apply the template, disregarding if the template is already installed." )
117
118
@click .option ('--remove-empty-dirs/--no-remove-empty-dirs' , 'remove_empty_directories' , is_flag = True , default = True ,
118
119
help = 'Remove empty directories when removing files' )
119
- @click .option ('--beta' , is_flag = True , default = False , show_default = True ,
120
- help = 'Allow applying beta templates' )
121
120
@project_option ()
122
121
@template_query (required = True )
123
122
@default_options
@@ -143,8 +142,8 @@ def install(ctx: click.Context, **kwargs):
143
142
help = "Force apply the template, disregarding if the template is already installed." )
144
143
@click .option ('--remove-empty-dirs/--no-remove-empty-dirs' , 'remove_empty_directories' , is_flag = True , default = True ,
145
144
help = 'Remove empty directories when removing files' )
146
- @click .option ('--beta ' , is_flag = True , default = False , show_default = True ,
147
- help = 'Allow upgrading to beta templates ' )
145
+ @click .option ('--early-access/--disable-early-access ' , '--early/--disable-early' , '-ea/-dea' , 'early_access' , '--beta/--disable-beta' , default = None ,
146
+ help = 'Create a project using the PROS 4 kernel ' )
148
147
@project_option ()
149
148
@template_query (required = False )
150
149
@default_options
@@ -205,8 +204,8 @@ def uninstall_template(project: c.Project, query: c.BaseTemplate, remove_user: b
205
204
help = 'Compile the project after creation' )
206
205
@click .option ('--build-cache' , is_flag = True , default = None , show_default = False ,
207
206
help = 'Build compile commands cache after creation. Overrides --compile-after if both are specified.' )
208
- @click .option ('--beta ' , is_flag = True , default = False , show_default = True ,
209
- help = 'Create a project with a beta template ' )
207
+ @click .option ('--early-access/--disable-early-access ' , '--early/--disable-early' , '-ea/-dea' , 'early_access' , '--beta/--disable-beta' , default = None ,
208
+ help = 'Create a project using the PROS 4 kernel ' )
210
209
@click .pass_context
211
210
@default_options
212
211
def new_project (ctx : click .Context , path : str , target : str , version : str ,
@@ -218,6 +217,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
218
217
Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
219
218
"""
220
219
analytics .send ("new-project" )
220
+ version_source = version .lower () == 'latest'
221
221
if version .lower () == 'latest' or not version :
222
222
version = '>0'
223
223
if not force_system and c .Project .find_project (path ) is not None :
@@ -228,7 +228,7 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
228
228
_conductor = c .Conductor ()
229
229
if target is None :
230
230
target = _conductor .default_target
231
- project = _conductor .new_project (path , target = target , version = version ,
231
+ project = _conductor .new_project (path , target = target , version = version , version_source = version_source ,
232
232
force_user = force_user , force_system = force_system ,
233
233
no_default_libs = no_default_libs , ** kwargs )
234
234
ui .echo ('New PROS Project was created:' , output_machine = False )
@@ -237,7 +237,10 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
237
237
if compile_after or build_cache :
238
238
with ui .Notification ():
239
239
ui .echo ('Building project...' )
240
- ctx .exit (project .compile ([], scan_build = build_cache ))
240
+ exit_code = project .compile ([], scan_build = build_cache )
241
+ if exit_code != 0 :
242
+ logger (__name__ ).error (f'Failed to make project: Exit Code { exit_code } ' , extra = {'sentry' : False })
243
+ raise click .ClickException ('Failed to build' )
241
244
242
245
except Exception as e :
243
246
pros .common .logger (__name__ ).exception (e )
@@ -255,13 +258,13 @@ def new_project(ctx: click.Context, path: str, target: str, version: str,
255
258
help = 'Force update all remote depots, ignoring automatic update checks' )
256
259
@click .option ('--limit' , type = int , default = 15 ,
257
260
help = 'The maximum number of displayed results for each library' )
258
- @click .option ('--beta ' , is_flag = True , default = False , show_default = True ,
259
- help = 'View beta templates in the listing ' )
261
+ @click .option ('--early-access/--disable-early-access ' , '--early/--disable-early' , '-ea/-dea' , 'early_access' , '--beta/--disable-beta' , default = None ,
262
+ help = 'View a list of early access templates ' )
260
263
@template_query (required = False )
261
264
@click .pass_context
262
265
@default_options
263
266
def query_templates (ctx , query : c .BaseTemplate , allow_offline : bool , allow_online : bool , force_refresh : bool ,
264
- limit : int , beta : bool ):
267
+ limit : int , early_access : bool ):
265
268
"""
266
269
Query local and remote templates based on a spec
267
270
@@ -271,10 +274,10 @@ def query_templates(ctx, query: c.BaseTemplate, allow_offline: bool, allow_onlin
271
274
if limit < 0 :
272
275
limit = 15
273
276
templates = c .Conductor ().resolve_templates (query , allow_offline = allow_offline , allow_online = allow_online ,
274
- force_refresh = force_refresh , beta = beta )
275
- if beta :
277
+ force_refresh = force_refresh , early_access = early_access )
278
+ if early_access :
276
279
templates += c .Conductor ().resolve_templates (query , allow_offline = allow_offline , allow_online = allow_online ,
277
- force_refresh = force_refresh , beta = False )
280
+ force_refresh = force_refresh , early_access = False )
278
281
279
282
render_templates = {}
280
283
for template in templates :
@@ -323,3 +326,46 @@ def info_project(project: c.Project, ls_upgrades):
323
326
template ["upgrades" ] = sorted ({t .version for t in templates }, key = lambda v : semver .Version (v ), reverse = True )
324
327
325
328
ui .finalize ('project-report' , report )
329
+
330
+ @conductor .command ('add-depot' )
331
+ @click .argument ('name' )
332
+ @click .argument ('url' )
333
+ @default_options
334
+ def add_depot (name : str , url : str ):
335
+ """
336
+ Add a depot
337
+
338
+ Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
339
+ """
340
+ _conductor = c .Conductor ()
341
+ _conductor .add_depot (name , url )
342
+
343
+ ui .echo (f"Added depot { name } from { url } " )
344
+
345
+ @conductor .command ('remove-depot' )
346
+ @click .argument ('name' )
347
+ @default_options
348
+ def remove_depot (name : str ):
349
+ """
350
+ Remove a depot
351
+
352
+ Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
353
+ """
354
+ _conductor = c .Conductor ()
355
+ _conductor .remove_depot (name )
356
+
357
+ ui .echo (f"Removed depot { name } " )
358
+
359
+ @conductor .command ('query-depots' )
360
+ @click .option ('--url' , is_flag = True )
361
+ @default_options
362
+ def query_depots (url : bool ):
363
+ """
364
+ Gets all the stored depots
365
+
366
+ Visit https://pros.cs.purdue.edu/v5/cli/conductor.html to learn more
367
+ """
368
+ _conductor = c .Conductor ()
369
+ ui .echo (f"Available Depots{ ' (Add --url for the url)' if not url else '' } :\n " )
370
+ ui .echo ('\n ' .join (_conductor .query_depots (url ))+ "\n " )
371
+
0 commit comments