Conversation
Add CLI command to list dedicated servers, showing ID, name, location, and IP. The server ID can be used with `--region server-<id>` when creating projects on dedicated servers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThis pull request introduces a new Changes
Sequence DiagramsequenceDiagram
participant User as User/CLI
participant ListCmd as List Command
participant ApiClient as API Client
participant ServerModel as Server Model
participant Printer as Table Printer
User->>ListCmd: Execute list command
ListCmd->>ApiClient: GetServers(context.Background())
ApiClient-->>ListCmd: []Server
ListCmd->>ServerModel: Convert to Servers type
ServerModel->>ServerModel: Header() → column labels
ServerModel->>ServerModel: Rows() → formatted data rows
ListCmd->>Printer: Table(headers, rows)
Printer-->>User: Display server table
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/model/server.go (1)
36-55: Optional: extract a sharedLocation()formatter to avoid duplication.The location formatting logic now lives in both
Server.String()andServers.Rows(). A small helper onServerkeeps this DRY and ensures future changes stay consistent.♻️ Suggested refactor
func (s Server) String() string { - var identifier string - - if s.Country != nil { - identifier = *s.Country - if s.City != nil { - identifier = fmt.Sprintf("%s, %s", *s.City, *s.Country) - } - } else { - identifier = s.IP - } + identifier := s.Location() return fmt.Sprintf("%s (%s)", s.Name, identifier) } + +func (s Server) Location() string { + if s.Country != nil { + if s.City != nil { + return fmt.Sprintf("%s, %s", *s.City, *s.Country) + } + return *s.Country + } + return s.IP +} @@ for i, server := range s { - location := server.IP - if server.Country != nil { - location = *server.Country - if server.City != nil { - location = fmt.Sprintf("%s, %s", *server.City, *server.Country) - } - } + location := server.Location() rows[i] = []string{server.GetID(), server.Name, location, server.IP} }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/model/server.go` around lines 36 - 55, Extract the duplicated location formatting into a method on Server (e.g., Location() or LocationString()) and replace the inline logic in Servers.Rows() with a call to that method; also update Server.String() to use the same method so both places share the formatting logic. Ensure the new Server.Location() returns the same string currently constructed (city, country fallback to IP) and update Servers.Rows() to use server.Location() for the location column instead of duplicating the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/model/server.go`:
- Around line 36-55: Extract the duplicated location formatting into a method on
Server (e.g., Location() or LocationString()) and replace the inline logic in
Servers.Rows() with a call to that method; also update Server.String() to use
the same method so both places share the formatting logic. Ensure the new
Server.Location() returns the same string currently constructed (city, country
fallback to IP) and update Servers.Rows() to use server.Location() for the
location column instead of duplicating the logic.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
internal/cmd/root/root.gointernal/cmd/server/list/list.gointernal/cmd/server/server.gopkg/model/server.go
There was a problem hiding this comment.
Pull request overview
This PR introduces a new zeabur server list CLI command to display dedicated server information, and adds a Servers tabular model to render the results.
Changes:
- Add
servercommand group withserver listsubcommand. - Fetch servers via API and print a table with ID/name/location/IP.
- Add
model.ServerswithHeader()/Rows()helpers for table rendering.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/model/server.go | Adds Servers slice type with table header/row formatting for server listing output. |
| internal/cmd/server/server.go | Introduces the top-level server command and wires in subcommands. |
| internal/cmd/server/list/list.go | Implements zeabur server list by calling ApiClient.GetServers and printing a table. |
| internal/cmd/root/root.go | Registers the new server command in the CLI root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| location := server.IP | ||
| if server.Country != nil { | ||
| location = *server.Country | ||
| if server.City != nil { | ||
| location = fmt.Sprintf("%s, %s", *server.City, *server.Country) | ||
| } | ||
| } | ||
| rows[i] = []string{server.GetID(), server.Name, location, server.IP} | ||
| } |
There was a problem hiding this comment.
Location is initialized with server.IP, and the row also prints server.IP in the IP column. This makes the Location column duplicate the IP (and can be misleading when country/city is unknown). Consider using an explicit placeholder (e.g. "-"/empty) when Country is nil, and/or extracting a shared LocationString() helper so this formatting logic isn't duplicated with Server.String().
Summary
zeabur server listcommand to list dedicated servers (ID, name, location, IP)--region server-<id>when creating projects on dedicated serversServerstype withHeader()/Rows()table methods to the modelTest plan
zeabur server list -i=false— verified output shows dedicated servers🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
servercommand to manage dedicated serversserver listsubcommand to view all dedicated servers with details including ID, name, location, and IP address in a table format