@@ -51,10 +51,6 @@ func NewDeleteCommand(clients *shared.ClientFactory) *cobra.Command {
5151 cmd .Flags ().StringVar (& deleteCmdFlags .sandboxID , "sandbox-id" , "" , "Sandbox team ID to delete" )
5252 cmd .Flags ().BoolVar (& deleteCmdFlags .force , "force" , false , "Skip confirmation prompt" )
5353
54- if err := cmd .MarkFlagRequired ("sandbox-id" ); err != nil {
55- panic (err )
56- }
57-
5854 return cmd
5955}
6056
@@ -66,13 +62,27 @@ func runDeleteCommand(cmd *cobra.Command, clients *shared.ClientFactory) error {
6662 return err
6763 }
6864
65+ sandboxID := deleteCmdFlags .sandboxID
66+ if sandboxID == "" {
67+ sandboxID , err = clients .IO .InputPrompt (
68+ ctx ,
69+ "Enter the ID of the sandbox" ,
70+ iostreams.InputPromptConfig {
71+ Required : true ,
72+ },
73+ )
74+ if err != nil {
75+ return err
76+ }
77+ }
78+
6979 skipConfirm := deleteCmdFlags .force
7080 if ! skipConfirm {
7181 clients .IO .PrintInfo (ctx , false , "\n %s" , style .Sectionf (style.TextSection {
7282 Emoji : "warning" ,
7383 Text : style .Bold (" Danger zone" ),
7484 Secondary : []string {
75- fmt .Sprintf ("Sandbox (%s) and all of its data will be permanently deleted" , deleteCmdFlags . sandboxID ),
85+ fmt .Sprintf ("Sandbox (%s) and all of its data will be permanently deleted" , sandboxID ),
7686 "This cannot be undone" ,
7787 },
7888 }))
@@ -93,15 +103,15 @@ func runDeleteCommand(cmd *cobra.Command, clients *shared.ClientFactory) error {
93103 }
94104 }
95105
96- if err := clients .API ().DeleteSandbox (ctx , auth .Token , deleteCmdFlags . sandboxID ); err != nil {
106+ if err := clients .API ().DeleteSandbox (ctx , auth .Token , sandboxID ); err != nil {
97107 return err
98108 }
99109
100110 clients .IO .PrintInfo (ctx , false , "\n %s" , style .Sectionf (style.TextSection {
101111 Emoji : "white_check_mark" ,
102112 Text : "Sandbox Deleted" ,
103113 Secondary : []string {
104- "Sandbox " + deleteCmdFlags . sandboxID + " has been permanently deleted" ,
114+ "Sandbox " + sandboxID + " has been permanently deleted" ,
105115 },
106116 }))
107117
0 commit comments