Skip to content

feat: add server list command#176

Merged
canyugs merged 1 commit intomainfrom
can/pla-576-cli-add-server-list-for-create-project
Feb 25, 2026
Merged

feat: add server list command#176
canyugs merged 1 commit intomainfrom
can/pla-576-cli-add-server-list-for-create-project

Conversation

@canyugs
Copy link
Contributor

@canyugs canyugs commented Feb 24, 2026

Summary

  • Add zeabur server list command to list dedicated servers (ID, name, location, IP)
  • Server IDs can be used with --region server-<id> when creating projects on dedicated servers
  • Add Servers type with Header()/Rows() table methods to the model

Test plan

  • Built CLI and ran zeabur server list -i=false — verified output shows dedicated servers
  • Used returned server ID to create a project on a dedicated server and deploy a template successfully

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new server command to manage dedicated servers
    • Added server list subcommand to view all dedicated servers with details including ID, name, location, and IP address in a table format

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>
Copilot AI review requested due to automatic review settings February 24, 2026 16:25
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Walkthrough

This pull request introduces a new server root command with a list subcommand to manage dedicated servers. The changes include command registration in the root command hierarchy, a server command module with list subcommand, API client integration to fetch servers, and table rendering helpers for displaying server data in columnar format.

Changes

Cohort / File(s) Summary
Command Registration
internal/cmd/root/root.go
Imports the server command package and registers NewCmdServer(f) as a child command in the root command.
Server Command Structure
internal/cmd/server/server.go, internal/cmd/server/list/list.go
Creates the server root command with "Manage dedicated servers" description and wires the list subcommand. Implements list command that fetches servers via ApiClient.GetServers() and renders results as a table.
Server Model
pkg/model/server.go
Adds Servers collection type with Header() and Rows() methods to support tabular rendering of server data with columns for ID, Name, Location (derived from Country/City or IP), and IP address.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add server list command' directly and clearly describes the main change: introducing a new 'server list' command to the CLI, which is confirmed by the PR objectives and all file changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch can/pla-576-cli-add-server-list-for-create-project

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/model/server.go (1)

36-55: Optional: extract a shared Location() formatter to avoid duplication.

The location formatting logic now lives in both Server.String() and Servers.Rows(). A small helper on Server keeps 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

📥 Commits

Reviewing files that changed from the base of the PR and between 429f5f5 and ab0f5e4.

📒 Files selected for processing (4)
  • internal/cmd/root/root.go
  • internal/cmd/server/list/list.go
  • internal/cmd/server/server.go
  • pkg/model/server.go

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 server command group with server list subcommand.
  • Fetch servers via API and print a table with ID/name/location/IP.
  • Add model.Servers with Header() / 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.

Comment on lines +45 to +53
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}
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copilot uses AI. Check for mistakes.
@canyugs canyugs merged commit 6e586c9 into main Feb 25, 2026
9 checks passed
@canyugs canyugs deleted the can/pla-576-cli-add-server-list-for-create-project branch February 25, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants