@@ -259,8 +259,12 @@ impl App {
259259 Xtasks :: Macros { macro_name } => {
260260 cmd. arg ( "macros" ) . arg ( macro_name. as_ref ( ) ) ;
261261 }
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+ }
264268 }
265269 Xtasks :: Build => {
266270 cmd. arg ( "build" ) ;
@@ -486,7 +490,11 @@ enum Xtasks {
486490 macro_name : Macro ,
487491 } ,
488492 /// 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+ } ,
490498 /// Build the main workspace only
491499 Build ,
492500 /// Build the main workspace, apply all prefferred lints
@@ -583,7 +591,7 @@ impl Xtasks {
583591 Xtasks :: Docs { open, no_rust_docs } => Self :: docs ( app_settings, open, no_rust_docs) ,
584592 Xtasks :: Test { name, package } => Self :: test ( app_settings, package, name) ,
585593 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 ) ,
587595 Xtasks :: Macros { macro_name } => match macro_name {
588596 Macro :: ScriptTests => {
589597 let mut settings = app_settings. clone ( ) ;
@@ -1290,7 +1298,7 @@ impl Xtasks {
12901298 Ok ( ( ) )
12911299 }
12921300
1293- fn init ( app_settings : GlobalArgs ) -> Result < ( ) > {
1301+ fn init ( app_settings : GlobalArgs , dont_update_ide : bool ) -> Result < ( ) > {
12941302 // install cargo mdbook
12951303 Self :: run_system_command (
12961304 & app_settings,
@@ -1350,34 +1358,38 @@ impl Xtasks {
13501358
13511359 // create .vscode settings
13521360 // 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+ }
13811393 }
13821394
13831395 Ok ( ( ) )
0 commit comments