Skip to content

Comments

feat: add --project-id to service list & search templates by service name#172

Merged
yuaanlin merged 1 commit intomainfrom
feat/service-list-project-id-and-template-search-services
Feb 20, 2026
Merged

feat: add --project-id to service list & search templates by service name#172
yuaanlin merged 1 commit intomainfrom
feat/service-list-project-id-and-template-search-services

Conversation

@yuaanlin
Copy link
Member

@yuaanlin yuaanlin commented Feb 20, 2026

Summary

  • Add --project-id flag to service list so it can be used directly without setting context first (e.g. zeabur service list --project-id <id>)
  • Enhance template search to also match service names within templates — e.g. searching "mysql" will return templates that include a MySQL service, ranked below direct title/description matches

Test plan

  • zeabur service list --project-id <id> works without setting context
  • zeabur template search mysql returns templates containing MySQL services
  • Title/description matches still rank above service name matches

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added --project-id flag to explicitly specify a project ID for non-interactive workflows
    • Implemented relevance scoring for template search results, prioritizing matches by name, description, and service relevance
  • Improvements

    • Enhanced template search output with explicit messaging when no matching templates are found

…ervice name

- Add --project-id flag to `service list` so it can be used without setting context
- Enhance `template search` to also match service names within templates (ranked lower than title/description matches)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2026

Walkthrough

Adds explicit project ID flag support with context fallback logic to the service list command. Introduces relevance scoring for template search results based on keyword matching. Extends Template model with Services field and updates related utility function signatures accordingly.

Changes

Cohort / File(s) Summary
Project ID Support
internal/cmd/service/list/list.go, internal/util/runE.go
Added --project-id flag for explicit project selection. Updated NeedProjectContextWhenNonInteractive to accept optional overrideID parameter; short-circuits check when override is provided. Enables non-interactive flows to use explicit flag values while maintaining fallback to context/prompts.
Template Search Scoring
internal/cmd/template/search/search.go
Implemented relevance scoring mechanism for template search results. Scoring rules: name match (3 points), description match (2 points), service name match (1 point). Results sorted by score descending, then by DeploymentCnt. Prints "No templates found" when no matches.
Template Model Extension
pkg/model/template.go
Added TemplateServiceRef struct with Name field and extended Template struct with Services field (slice of TemplateServiceRef) to track associated template services.

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 20.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 clearly summarizes the main changes: adding a --project-id flag to service list and enhancing template search with service name matching.

✏️ 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 feat/service-list-project-id-and-template-search-services

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)
internal/cmd/service/list/list.go (1)

52-56: Redundant context fetch.

Line 19 already initializes opts.projectID from f.Config.GetContext().GetProject().GetID() during command construction. The re-fetch on lines 54-56 will retrieve the same value, making this block unnecessary.

♻️ Suggested simplification
 func runListInteractive(f *cmdutil.Factory, opts *Options) error {
-	// if project id is not set by flag, fetch from context
-	if opts.projectID == "" {
-		opts.projectID = f.Config.GetContext().GetProject().GetID()
-	}
-
 	// if project id is still not set, prompt to select one
 	if _, err := f.ParamFiller.Project(&opts.projectID); err != nil {
 		return err
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/cmd/service/list/list.go` around lines 52 - 56, The block in
runListInteractive that re-fetches opts.projectID from
f.Config.GetContext().GetProject().GetID() is redundant because opts.projectID
is already initialized during command construction; remove the conditional that
checks if opts.projectID == "" and the assignment inside it to avoid duplicate
context reads and simplify the function while keeping any flag-provided
projectID handling intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/cmd/service/list/list.go`:
- Around line 52-56: The block in runListInteractive that re-fetches
opts.projectID from f.Config.GetContext().GetProject().GetID() is redundant
because opts.projectID is already initialized during command construction;
remove the conditional that checks if opts.projectID == "" and the assignment
inside it to avoid duplicate context reads and simplify the function while
keeping any flag-provided projectID handling intact.

@yuaanlin yuaanlin merged commit a6adc3f into main Feb 20, 2026
5 checks passed
@yuaanlin yuaanlin deleted the feat/service-list-project-id-and-template-search-services branch February 20, 2026 05:06
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.

1 participant