@@ -21,6 +21,7 @@ import (
2121 "time"
2222 "unicode"
2323
24+ "github.com/slackapi/slack-cli/internal/iostreams"
2425 "github.com/slackapi/slack-cli/internal/shared"
2526 "github.com/slackapi/slack-cli/internal/slackerror"
2627 "github.com/slackapi/slack-cli/internal/style"
@@ -98,13 +99,6 @@ func NewCreateCommand(clients *shared.ClientFactory) *cobra.Command {
9899 // If one's developer account is managed by multiple Production Slack teams, one of those team IDs must be provided in the command
99100 cmd .Flags ().StringVar (& createCmdFlags .owningOrgID , "owning-org-id" , "" , "Enterprise team ID that manages your developer account, if applicable" )
100101
101- if err := cmd .MarkFlagRequired ("name" ); err != nil {
102- panic (err )
103- }
104- if err := cmd .MarkFlagRequired ("password" ); err != nil {
105- panic (err )
106- }
107-
108102 return cmd
109103}
110104
@@ -116,10 +110,38 @@ func runCreateCommand(cmd *cobra.Command, clients *shared.ClientFactory) error {
116110 return err
117111 }
118112
113+ name := createCmdFlags .name
114+ if name == "" {
115+ name , err = clients .IO .InputPrompt (
116+ ctx ,
117+ "Enter a name for the sandbox" ,
118+ iostreams.InputPromptConfig {
119+ Required : true ,
120+ },
121+ )
122+ if err != nil {
123+ return err
124+ }
125+ }
126+
127+ password := createCmdFlags .password
128+ if password == "" {
129+ password , err = clients .IO .InputPrompt (
130+ ctx ,
131+ "Enter a password for the sandbox" ,
132+ iostreams.InputPromptConfig {
133+ Required : true ,
134+ },
135+ )
136+ if err != nil {
137+ return err
138+ }
139+ }
140+
119141 domain := createCmdFlags .domain
120142 if domain == "" {
121143 var err error
122- domain , err = domainFromName (createCmdFlags . name )
144+ domain , err = domainFromName (name )
123145 if err != nil {
124146 return err
125147 }
@@ -149,9 +171,9 @@ func runCreateCommand(cmd *cobra.Command, clients *shared.ClientFactory) error {
149171 }
150172
151173 teamID , sandboxURL , err := clients .API ().CreateSandbox (ctx , auth .Token ,
152- createCmdFlags . name ,
174+ name ,
153175 domain ,
154- createCmdFlags . password ,
176+ password ,
155177 createCmdFlags .locale ,
156178 createCmdFlags .owningOrgID ,
157179 templateID ,
@@ -170,7 +192,6 @@ func runCreateCommand(cmd *cobra.Command, clients *shared.ClientFactory) error {
170192
171193// getEpochFromTTL parses a time-to-live string (e.g., "1d", "2w", "3mo") and returns the Unix epoch
172194// when the sandbox will be archived. Supports days (d), weeks (w), and months (mo).
173- // Minimum is 1 day, maximum is 6 months.
174195func getEpochFromTTL (ttl string ) (int64 , error ) {
175196 lower := strings .TrimSpace (strings .ToLower (ttl ))
176197 if lower == "" {
@@ -206,7 +227,7 @@ func getEpochFromTTL(ttl string) (int64, error) {
206227 return target .Unix (), nil
207228}
208229
209- // getEpochFromDate parses a date in yyyy-mm-dd format and returns the Unix epoch at start of that day (UTC).
230+ // getEpochFromDate parses a date in yyyy-mm-dd format and returns the Unix epoch at the start of that day (UTC)
210231func getEpochFromDate (dateStr string ) (int64 , error ) {
211232 dateFormat := "2006-01-02"
212233 t , err := time .ParseInLocation (dateFormat , dateStr , time .UTC )
0 commit comments