## 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>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package unifi
|
|
|
|
import (
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
|
"forge.lthn.ai/core/go/pkg/log"
|
|
uf "forge.lthn.ai/core/go/pkg/unifi"
|
|
)
|
|
|
|
// addSitesCommand adds the 'sites' subcommand for listing UniFi sites.
|
|
func addSitesCommand(parent *cli.Command) {
|
|
cmd := &cli.Command{
|
|
Use: "sites",
|
|
Short: "List controller sites",
|
|
Long: "List all sites configured on the UniFi controller.",
|
|
RunE: func(cmd *cli.Command, args []string) error {
|
|
return runSites()
|
|
},
|
|
}
|
|
|
|
parent.AddCommand(cmd)
|
|
}
|
|
|
|
func runSites() error {
|
|
client, err := uf.NewFromConfig("", "", "", "", nil)
|
|
if err != nil {
|
|
return log.E("unifi.sites", "failed to initialise client", err)
|
|
}
|
|
|
|
sites, err := client.GetSites()
|
|
if err != nil {
|
|
return log.E("unifi.sites", "failed to fetch sites", err)
|
|
}
|
|
|
|
if len(sites) == 0 {
|
|
cli.Text("No sites found.")
|
|
return nil
|
|
}
|
|
|
|
table := cli.NewTable("Name", "Description")
|
|
|
|
for _, s := range sites {
|
|
table.AddRow(
|
|
valueStyle.Render(s.Name),
|
|
dimStyle.Render(s.Desc),
|
|
)
|
|
}
|
|
|
|
cli.Blank()
|
|
cli.Print(" %d sites\n\n", len(sites))
|
|
table.Render()
|
|
|
|
return nil
|
|
}
|