github.com/supabase/cli@v1.168.1/internal/functions/list/list.go (about) 1 package list 2 3 import ( 4 "context" 5 "fmt" 6 "time" 7 8 "github.com/go-errors/errors" 9 "github.com/spf13/afero" 10 "github.com/supabase/cli/internal/migration/list" 11 "github.com/supabase/cli/internal/utils" 12 ) 13 14 func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { 15 resp, err := utils.GetSupabase().GetFunctionsWithResponse(ctx, projectRef) 16 if err != nil { 17 return errors.Errorf("failed to list functions: %w", err) 18 } 19 20 if resp.JSON200 == nil { 21 return errors.New("Unexpected error retrieving functions: " + string(resp.Body)) 22 } 23 24 table := `|ID|NAME|SLUG|STATUS|VERSION|UPDATED_AT (UTC)| 25 |-|-|-|-|-|-| 26 ` 27 for _, function := range *resp.JSON200 { 28 t := time.UnixMilli(int64(function.UpdatedAt)) 29 table += fmt.Sprintf( 30 "|`%s`|`%s`|`%s`|`%s`|`%d`|`%s`|\n", 31 function.Id, 32 function.Name, 33 function.Slug, 34 function.Status, 35 uint64(function.Version), 36 t.UTC().Format("2006-01-02 15:04:05"), 37 ) 38 } 39 40 return list.RenderTable(table) 41 }