feat(cli): add project selector to service commands#893
Merged
Conversation
m-abdelwahab
approved these changes
May 11, 2026
There was a problem hiding this comment.
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,--environmentwhen--projectis 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
--projectis 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--projectsupport 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--projectrequire--environmentto avoid ambiguous cross-project environment resolution.Changes
Add
--projectsupport 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
--projectis omitted.Preserve single-service fallback behavior for commands that can infer the target service.
Use
--projectwithout a short flag fordomainbecause-pis already used for--port.Adds
--projectto:railway logsrailway metricsrailway variablerailway variable listrailway variable setrailway variable deleterailway service listrailway service statusrailway service deleterailway redeployrailway restartrailway downrailway scalerailway service scalerailway shellrailway connectrailway volumerailway domainNote:
railway domaingets--projectonly, not-p, because-pis already--port.Test plan
cargo fmtcargo checkcargo testservice status --project ... --environment ... --service ... --jsonlogs --project ... --environment ... --service ... --lines 1 --jsonmetrics --project ... --environment ... --service ... --json --cpu