(ctx context.Context, isWithDeprecatedFlag bool)
| 11 | ) |
| 12 | |
| 13 | func List(ctx context.Context, isWithDeprecatedFlag bool) error { |
| 14 | c, err := config.ScalingoClient(ctx) |
| 15 | if err != nil { |
| 16 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 17 | } |
| 18 | |
| 19 | stacks, err := c.StacksList(ctx) |
| 20 | if err != nil { |
| 21 | return errors.Wrapf(ctx, err, "fail to list available stacks") |
| 22 | } |
| 23 | |
| 24 | t := tablewriter.NewWriter(os.Stdout) |
| 25 | |
| 26 | if isWithDeprecatedFlag { |
| 27 | t.Header([]string{"ID", "Name", "Description", "Default?", "Deprecated?", "Deprecation date"}) |
| 28 | } else { |
| 29 | t.Header([]string{"ID", "Name", "Description", "Default?"}) |
| 30 | } |
| 31 | |
| 32 | for _, stack := range stacks { |
| 33 | defaultText := "No" |
| 34 | if stack.Default { |
| 35 | defaultText = "Yes" |
| 36 | } |
| 37 | |
| 38 | if isWithDeprecatedFlag { |
| 39 | deprecatedText := "No" |
| 40 | deprecationDate := "" |
| 41 | |
| 42 | if stack.IsDeprecated() { |
| 43 | deprecatedText = "Yes" |
| 44 | } |
| 45 | |
| 46 | if !stack.DeprecatedAt.IsZero() { |
| 47 | deprecationDate = stack.DeprecatedAt.Format("2006-01-02") |
| 48 | } |
| 49 | |
| 50 | t.Append([]string{stack.ID, stack.Name, stack.Description, defaultText, deprecatedText, deprecationDate}) |
| 51 | } else if !stack.IsDeprecated() { |
| 52 | t.Append([]string{stack.ID, stack.Name, stack.Description, defaultText}) |
| 53 | } |
| 54 | } |
| 55 | t.Render() |
| 56 | return nil |
| 57 | } |
no test coverage detected