@@ -259,8 +259,12 @@ impl App {
259
259
Xtasks :: Macros { macro_name } => {
260
260
cmd. arg ( "macros" ) . arg ( macro_name. as_ref ( ) ) ;
261
261
}
262
- Xtasks :: Init => {
263
- cmd. arg ( "init" ) ;
262
+ Xtasks :: Init { dont_update_ide } => {
263
+ let arg = cmd. arg ( "init" ) ;
264
+
265
+ if dont_update_ide {
266
+ arg. arg ( "--dont-update-ide" ) ;
267
+ }
264
268
}
265
269
Xtasks :: Build => {
266
270
cmd. arg ( "build" ) ;
@@ -486,7 +490,11 @@ enum Xtasks {
486
490
macro_name : Macro ,
487
491
} ,
488
492
/// Performs first time local-development environment setup
489
- Init ,
493
+ Init {
494
+ /// Prevents updating the IDE settings, defaults to false
495
+ #[ clap( long, default_value = "false" ) ]
496
+ dont_update_ide : bool ,
497
+ } ,
490
498
/// Build the main workspace only
491
499
Build ,
492
500
/// Build the main workspace, apply all prefferred lints
@@ -583,7 +591,7 @@ impl Xtasks {
583
591
Xtasks :: Docs { open, no_rust_docs } => Self :: docs ( app_settings, open, no_rust_docs) ,
584
592
Xtasks :: Test { name, package } => Self :: test ( app_settings, package, name) ,
585
593
Xtasks :: CiCheck => Self :: cicd ( app_settings) ,
586
- Xtasks :: Init => Self :: init ( app_settings) ,
594
+ Xtasks :: Init { dont_update_ide } => Self :: init ( app_settings, dont_update_ide ) ,
587
595
Xtasks :: Macros { macro_name } => match macro_name {
588
596
Macro :: ScriptTests => {
589
597
let mut settings = app_settings. clone ( ) ;
@@ -1290,7 +1298,7 @@ impl Xtasks {
1290
1298
Ok ( ( ) )
1291
1299
}
1292
1300
1293
- fn init ( app_settings : GlobalArgs ) -> Result < ( ) > {
1301
+ fn init ( app_settings : GlobalArgs , dont_update_ide : bool ) -> Result < ( ) > {
1294
1302
// install cargo mdbook
1295
1303
Self :: run_system_command (
1296
1304
& app_settings,
@@ -1350,34 +1358,38 @@ impl Xtasks {
1350
1358
1351
1359
// create .vscode settings
1352
1360
// read from templates at compile time
1353
- let vscode_settings = include_str ! ( "../templates/settings.json.tera" ) ;
1354
- let mut tera = tera:: Tera :: default ( ) ;
1355
- let mut context = tera:: Context :: new ( ) ;
1356
- let workspace_dir = Self :: workspace_dir ( & app_settings) ?;
1357
- let json_workspace_dir = serde_json:: to_string ( & workspace_dir) ?; // make sure this works as a json string
1358
- context. insert ( "dir" , & json_workspace_dir. trim_matches ( '\"' ) ) ;
1359
-
1360
- let templated_settings = tera. render_str ( vscode_settings, & context) ?;
1361
- let templated_settings_json = Self :: read_json_with_comments ( templated_settings. as_bytes ( ) )
1362
- . with_context ( || "reading templated vscode settings" ) ?;
1363
- let vscode_dir = Self :: relative_workspace_dir ( & app_settings, ".vscode" ) ?;
1364
- std:: fs:: create_dir_all ( & vscode_dir) ?;
1365
- let vscode_settings_path = vscode_dir. join ( "settings.json" ) ;
1366
-
1367
- // if the file already exists, merge the settings otherwise create it
1368
- info ! (
1369
- "Merging vscode settings at {:?}. With overrides generated by template." ,
1370
- vscode_settings_path
1371
- ) ;
1372
- if vscode_settings_path. exists ( ) {
1373
- let existing_settings = std:: fs:: read_to_string ( & vscode_settings_path) ?;
1374
- let mut existing_settings = Self :: read_json_with_comments ( existing_settings. as_bytes ( ) )
1375
- . with_context ( || "reading existing vscode settings file" ) ?;
1376
- Self :: merge_json ( templated_settings_json, & mut existing_settings) ;
1377
- let merged_settings = serde_json:: to_string_pretty ( & existing_settings) ?;
1378
- std:: fs:: write ( & vscode_settings_path, merged_settings) ?;
1379
- } else {
1380
- std:: fs:: write ( & vscode_settings_path, templated_settings) ?;
1361
+ if !dont_update_ide {
1362
+ let vscode_settings = include_str ! ( "../templates/settings.json.tera" ) ;
1363
+ let mut tera = tera:: Tera :: default ( ) ;
1364
+ let mut context = tera:: Context :: new ( ) ;
1365
+ let workspace_dir = Self :: workspace_dir ( & app_settings) ?;
1366
+ let json_workspace_dir = serde_json:: to_string ( & workspace_dir) ?; // make sure this works as a json string
1367
+ context. insert ( "dir" , & json_workspace_dir. trim_matches ( '\"' ) ) ;
1368
+
1369
+ let templated_settings = tera. render_str ( vscode_settings, & context) ?;
1370
+ let templated_settings_json =
1371
+ Self :: read_json_with_comments ( templated_settings. as_bytes ( ) )
1372
+ . with_context ( || "reading templated vscode settings" ) ?;
1373
+ let vscode_dir = Self :: relative_workspace_dir ( & app_settings, ".vscode" ) ?;
1374
+ std:: fs:: create_dir_all ( & vscode_dir) ?;
1375
+ let vscode_settings_path = vscode_dir. join ( "settings.json" ) ;
1376
+
1377
+ // if the file already exists, merge the settings otherwise create it
1378
+ info ! (
1379
+ "Merging vscode settings at {:?}. With overrides generated by template." ,
1380
+ vscode_settings_path
1381
+ ) ;
1382
+ if vscode_settings_path. exists ( ) {
1383
+ let existing_settings = std:: fs:: read_to_string ( & vscode_settings_path) ?;
1384
+ let mut existing_settings =
1385
+ Self :: read_json_with_comments ( existing_settings. as_bytes ( ) )
1386
+ . with_context ( || "reading existing vscode settings file" ) ?;
1387
+ Self :: merge_json ( templated_settings_json, & mut existing_settings) ;
1388
+ let merged_settings = serde_json:: to_string_pretty ( & existing_settings) ?;
1389
+ std:: fs:: write ( & vscode_settings_path, merged_settings) ?;
1390
+ } else {
1391
+ std:: fs:: write ( & vscode_settings_path, templated_settings) ?;
1392
+ }
1381
1393
}
1382
1394
1383
1395
Ok ( ( ) )
0 commit comments