Skip to content

feat(cli): add project selector to service commands#893

Merged
half0wl merged 2 commits into
masterfrom
rc/service-resolver
May 11, 2026
Merged

feat(cli): add project selector to service commands#893
half0wl merged 2 commits into
masterfrom
rc/service-resolver

Conversation

@half0wl
Copy link
Copy Markdown
Member

@half0wl half0wl commented May 11, 2026

Summary

Adds --project support across service-scoped CLI commands so automation can target a project without first linking the working directory. This centralizes project/environment/service resolution in a shared resolver and keeps existing linked-project behavior as the default. Commands that accept --project require --environment to avoid ambiguous cross-project environment resolution.

Changes

  • Add --project support to service-scoped commands including logs, metrics, variables, service list/status/delete, redeploy, restart, down, scale, shell, connect, volume, and domain.

  • Introduce shared service context resolution for project, environment, and service IDs.

  • Preserve linked project/environment/service fallbacks when --project is omitted.

  • Preserve single-service fallback behavior for commands that can infer the target service.

  • Use --project without a short flag for domain because -p is already used for --port.

  • Adds --project to:

    • railway logs
    • railway metrics
    • railway variable
    • railway variable list
    • railway variable set
    • railway variable delete
    • railway service list
    • railway service status
    • railway service delete
    • railway redeploy
    • railway restart
    • railway down
    • railway scale
    • railway service scale
    • railway shell
    • railway connect
    • railway volume
    • railway domain
  • Note: railway domain gets --project only, not -p, because -p is already --port.

Test plan

  • cargo fmt
  • cargo check
  • cargo test
  • Manually verified service status --project ... --environment ... --service ... --json
  • Manually verified logs --project ... --environment ... --service ... --lines 1 --json
  • Manually verified metrics --project ... --environment ... --service ... --json --cpu

@half0wl half0wl added the release/patch Author patch release label May 11, 2026
@half0wl half0wl requested a review from m-abdelwahab May 11, 2026 00:24
Copy link
Copy Markdown

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 adds --project support to service-scoped CLI commands to allow targeting a project in automation without requiring a linked working directory, and centralizes project/environment/service resolution in a shared resolver while preserving linked-project defaults.

Changes:

  • Introduces resolve_service_context(project, service, environment) to consistently resolve project/environment/service IDs (with linked fallbacks and single-service inference).
  • Adds --project (and, in many cases, --environment when --project is used) across multiple service-scoped commands (logs, metrics, variable, shell, scale, restart/redeploy/down, service operations, volume, domain, connect).
  • Refactors commands to use the new resolver or shared project/environment selection logic, while maintaining existing linked behavior when --project is omitted.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/errors.rs Suppresses dead-code for an unused error variant after refactors.
src/controllers/project.rs Adds centralized service context resolver supporting explicit --project and single-service inference.
src/commands/volume.rs Adds --project and updates volume flow to resolve project/env/service accordingly.
src/commands/variable.rs Adds --project to variable subcommands and routes resolution through shared resolver.
src/commands/shell.rs Adds --project/--environment and uses shared resolver for selecting service context.
src/commands/service.rs Adds --project handling for list/status/delete flows and updates linked fallbacks.
src/commands/scale.rs Adds --project support and adjusts linked-service fallback plumbing.
src/commands/restart.rs Adds --project/--environment and switches to shared resolver for service targeting.
src/commands/redeploy.rs Adds --project/--environment and switches to shared resolver for service targeting.
src/commands/metrics.rs Adds --project and updates project/environment/service selection logic accordingly.
src/commands/logs.rs Adds --project and switches to shared resolver for service context.
src/commands/down.rs Adds --project and switches to shared resolver for service context.
src/commands/domain.rs Adds --project (long-only) and switches domain flows to shared resolver.
src/commands/connect.rs Adds --project and updates project/env resolution in connect flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/errors.rs Outdated
Comment thread src/controllers/project.rs
Comment thread src/commands/restart.rs
Comment thread src/commands/redeploy.rs Outdated
Comment thread src/commands/down.rs
@half0wl half0wl merged commit b09067b into master May 11, 2026
6 checks passed
@half0wl half0wl deleted the rc/service-resolver branch May 11, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/patch Author patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants