github.com/supabase/cli@v1.168.1/internal/orgs/list/list.go (about) 1 package list 2 3 import ( 4 "context" 5 "fmt" 6 "strings" 7 8 "github.com/go-errors/errors" 9 "github.com/supabase/cli/internal/migration/list" 10 "github.com/supabase/cli/internal/utils" 11 ) 12 13 func Run(ctx context.Context) error { 14 resp, err := utils.GetSupabase().GetOrganizationsWithResponse(ctx) 15 if err != nil { 16 return errors.Errorf("failed to list organizations: %w", err) 17 } 18 19 if resp.JSON200 == nil { 20 return errors.New("Unexpected error retrieving organizations: " + string(resp.Body)) 21 } 22 23 table := `|ID|NAME| 24 |-|-| 25 ` 26 for _, org := range *resp.JSON200 { 27 table += fmt.Sprintf("|`%s`|`%s`|\n", org.Id, strings.ReplaceAll(org.Name, "|", "\\|")) 28 } 29 30 return list.RenderTable(table) 31 }