1313
1414namespace Ymir \Cli \Command \Project ;
1515
16+ use Symfony \Component \Console \Input \InputArgument ;
1617use Symfony \Component \Console \Input \InputInterface ;
17- use Ymir \Cli \Command \AbstractProjectCommand ;
18+ use Ymir \Cli \Command \AbstractCommand ;
1819use Ymir \Cli \Console \ConsoleOutput ;
1920
20- class DeleteProjectCommand extends AbstractProjectCommand
21+ class DeleteProjectCommand extends AbstractCommand
2122{
2223 /**
2324 * The alias of the command.
@@ -40,7 +41,8 @@ protected function configure()
4041 {
4142 $ this
4243 ->setName (self ::NAME )
43- ->setDescription ('Delete the project ' )
44+ ->setDescription ('Delete a project ' )
45+ ->addArgument ('project ' , InputArgument::OPTIONAL , 'The ID or name of the project to delete ' )
4446 ->setAliases ([self ::ALIAS ]);
4547 }
4648
@@ -49,15 +51,25 @@ protected function configure()
4951 */
5052 protected function perform (InputInterface $ input , ConsoleOutput $ output )
5153 {
52- if (!$ output ->confirm ('Are you sure you want to delete this project? ' , false )) {
54+ $ projectId = $ this ->projectConfiguration ->exists () ? $ this ->projectConfiguration ->getProjectId () : null ;
55+
56+ if (null === $ projectId ) {
57+ $ projectId = $ this ->determineProject ('Which project would you like to delete ' , $ input , $ output );
58+ }
59+
60+ $ project = $ this ->apiClient ->getProject ($ projectId );
61+
62+ if (!$ output ->confirm (sprintf ('Are you sure you want to delete the <comment>%s</comment> project? ' , $ project ['name ' ]), false )) {
5363 return ;
5464 }
5565
5666 $ deleteResources = (bool ) $ output ->confirm ('Do you want to delete all the project resources on the cloud provider? ' , false );
5767
58- $ this ->apiClient ->deleteProject ($ this -> projectConfiguration -> getProjectId () , $ deleteResources );
68+ $ this ->apiClient ->deleteProject ($ projectId , $ deleteResources );
5969
60- $ this ->projectConfiguration ->delete ();
70+ if ($ this ->projectConfiguration ->exists () && $ projectId === $ this ->projectConfiguration ->getProjectId ()) {
71+ $ this ->projectConfiguration ->delete ();
72+ }
6173
6274 $ message = 'Project deleted ' ;
6375 $ deleteResources ? $ output ->infoWithDelayWarning ($ message ) : $ output ->info ($ message );
0 commit comments