@@ -28,7 +28,31 @@ func promptOrganizationID(ctx context.Context) (string, error) {
2828 })
2929}
3030
31+ func promptManualProjectID (ctx context.Context , defaultProjectID string ) (string , error ) {
32+ _ , _ = interactive .Println ()
33+ return interactive .PromptStringWithConfig (& interactive.PromptStringConfig {
34+ Ctx : ctx ,
35+ Prompt : "Choose your default project ID" ,
36+ DefaultValue : defaultProjectID ,
37+ DefaultValueDoc : defaultProjectID ,
38+ ValidateFunc : func (s string ) error {
39+ if ! validation .IsProjectID (s ) {
40+ return fmt .Errorf ("organization id is not a valid uuid" )
41+ }
42+ return nil
43+ },
44+ })
45+ }
46+
3147func promptProjectID (ctx context.Context , accessKey string , secretKey string , organizationID string , defaultProjectID string ) (string , error ) {
48+ if defaultProjectID == "" {
49+ defaultProjectID = organizationID
50+ }
51+
52+ if ! interactive .IsInteractive {
53+ return defaultProjectID , nil
54+ }
55+
3256 client := core .ExtractClient (ctx )
3357 api := account .NewAPI (client )
3458
@@ -39,6 +63,10 @@ func promptProjectID(ctx context.Context, accessKey string, secretKey string, or
3963 return "" , fmt .Errorf ("failed to list projects: %w" , err )
4064 }
4165
66+ if len (res .Projects ) == 0 {
67+ return promptManualProjectID (ctx , defaultProjectID )
68+ }
69+
4270 defaultIndex := 0
4371
4472 projects := make ([]string , len (res .Projects ))
0 commit comments