mirror of
https://github.com/coollabsio/coolify-cli.git
synced 2026-06-19 07:35:04 +00:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package github
|
|
|
|
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"
|
|
)
|
|
|
|
func NewListCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all GitHub App integrations",
|
|
Long: `List all GitHub App integrations configured in Coolify.`,
|
|
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)
|
|
}
|
|
|
|
// Check minimum version requirement
|
|
if err := cli.CheckMinimumVersion(ctx, client, "4.0.0-beta.436"); err != nil {
|
|
return err
|
|
}
|
|
|
|
svc := service.NewGitHubAppService(client)
|
|
apps, err := svc.List(ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to list GitHub Apps: %w", err)
|
|
}
|
|
|
|
format, _ := cmd.Flags().GetString("format")
|
|
formatter, err := output.NewFormatter(format, output.Options{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return formatter.Format(apps)
|
|
},
|
|
}
|
|
}
|