cli/cmd/forge/cmd_orgs.go
Claude 47e11e7861
refactor: flatten commands, extract php/ci variants to own repos
- Remove internal/cmd/php/ (now core/php repo)
- Remove internal/cmd/ci/ and internal/cmd/sdk/ (now core/ci repo)
- Remove internal/variants/ build tag system entirely
- Move all 30 remaining command packages from internal/cmd/ to cmd/
- Rewrite main.go with direct imports (no more variant selection)
- Update all cross-references from internal/cmd/ to cmd/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 14:44:28 +00:00

66 lines
1.2 KiB
Go

package forge
import (
"fmt"
"forge.lthn.ai/core/go/pkg/cli"
fg "forge.lthn.ai/core/go/pkg/forge"
)
// addOrgsCommand adds the 'orgs' subcommand for listing organisations.
func addOrgsCommand(parent *cli.Command) {
cmd := &cli.Command{
Use: "orgs",
Short: "List organisations",
Long: "List all organisations the authenticated user belongs to.",
RunE: func(cmd *cli.Command, args []string) error {
return runOrgs()
},
}
parent.AddCommand(cmd)
}
func runOrgs() error {
client, err := fg.NewFromConfig("", "")
if err != nil {
return err
}
orgs, err := client.ListMyOrgs()
if err != nil {
return err
}
if len(orgs) == 0 {
cli.Text("No organisations found.")
return nil
}
cli.Blank()
cli.Print(" %s\n\n", fmt.Sprintf("%d organisations", len(orgs)))
table := cli.NewTable("Name", "Visibility", "Description")
for _, org := range orgs {
visibility := successStyle.Render(org.Visibility)
if org.Visibility == "private" {
visibility = warningStyle.Render(org.Visibility)
}
desc := cli.Truncate(org.Description, 50)
if desc == "" {
desc = dimStyle.Render("-")
}
table.AddRow(
repoStyle.Render(org.UserName),
visibility,
desc,
)
}
table.Render()
return nil
}