mirror of
https://github.com/coollabsio/coolify-cli.git
synced 2026-06-19 07:35:04 +00:00
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package deployment
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/coollabsio/coolify-cli/internal/cli"
|
|
"github.com/coollabsio/coolify-cli/internal/output"
|
|
"github.com/coollabsio/coolify-cli/internal/service"
|
|
)
|
|
|
|
// NewListCommand lists all deployments
|
|
func NewListCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all deployments",
|
|
Long: `List all currently running deployments across all resources.`,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
ctx := cmd.Context()
|
|
|
|
client, err := cli.GetAPIClient(cmd)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get API client: %w", err)
|
|
}
|
|
|
|
deploySvc := service.NewDeploymentService(client)
|
|
deployments, err := deploySvc.List(ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to list deployments: %w", err)
|
|
}
|
|
|
|
format, _ := cmd.Flags().GetString("format")
|
|
formatter, err := output.NewFormatter(format, output.Options{})
|
|
if err != nil {
|
|
return fmt.Errorf("failed to create formatter: %w", err)
|
|
}
|
|
|
|
return formatter.Format(deployments)
|
|
},
|
|
}
|
|
}
|