@@ -51,6 +51,13 @@ final class ProjectAddCommand extends BaseCommand
5151 )]
5252protected ?string $ envFile =null ;
5353
54+ #[Option(
55+ name:'switch ' ,
56+ shortcut:'s ' ,
57+ description:'Switch to this project after adding it ' ,
58+ )]
59+ protected bool $ switch =false ;
60+
5461public function __invoke (
5562Container $ container ,
5663DirectoriesInterface $ dirs ,
@@ -132,6 +139,19 @@ public function __invoke(
132139$ projectService ->setCurrentProject ($ projectPath ,$ this ->name ,$ this ->configFile ,$ this ->envFile );
133140$ this ->output ->info ('Project was automatically set as the current project (first project added). ' );
134141 }
142+ // If --switch flag is set for subsequent projects, switch to it
143+ elseif ($ this ->switch ) {
144+ if ($ projectService ->switchToProject ($ projectPath )) {
145+ $ this ->output ->info ('Successfully switched to this project. ' );
146+ }else {
147+ $ this ->output ->warning (
148+ \sprintf (
149+ "Project added but failed to switch. Use 'ctx project %s' to switch manually. " ,
150+ $ this ->name ??$ projectPath ,
151+ ),
152+ );
153+ }
154+ }
135155
136156return Command::SUCCESS ;
137157 }