cli/cmd/forge/cmd_orgs.go
Charon c340303314 refactor: flatten commands, extract php/ci to own repos (#2)
## Summary
- Extract PHP/Laravel commands to `core/php` repo (42 files, standalone module)
- Extract CI/release + SDK commands to `core/ci` repo (10 files)
- Remove `internal/variants/` build tag system entirely
- Move all 30 remaining command packages from `internal/cmd/` to top-level `cmd/`
- Rewrite `main.go` with direct imports — no more variant selection
- PHP and CI are now optional via commented import lines in main.go

Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: #2
Co-authored-by: Charon <charon@lthn.ai>
Co-committed-by: Charon <charon@lthn.ai>
2026-02-16 14:45:06 +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
}