Skip to content

refactor(cli): extract gateway commands into commands/gateway module - #2506

Merged
drew merged 1 commit into
NVIDIA:mainfrom
varshaprasad96:vnarsing/cli-refactor-2
Jul 28, 2026
Merged

refactor(cli): extract gateway commands into commands/gateway module#2506
drew merged 1 commit into
NVIDIA:mainfrom
varshaprasad96:vnarsing/cli-refactor-2

Conversation

@varshaprasad96

Copy link
Copy Markdown
Contributor

Summary

  • Extracts all gateway management functions (10 public, 29 private helpers) and 31 tests from the monolithic run.rs (~10,600 lines) into commands/gateway.rs
  • Adds pub use re-exports in run.rs so main.rs call sites remain unchanged
  • Moves shared test utilities (EnvVarGuard, with_tmp_xdg) to a new test_utils.rs module for reuse across test modules

This is PR 2 of 6 in the CLI refactor series (tracking issue #2304). PR 1 (#2359) created the commands/ directory scaffold; this PR populates it with the gateway command group.

Related Issue

Closes part of #2304 (PR 2: Gateway commands extraction)

Changes

File Change
commands/gateway.rs New — 10 public gateway functions, 29 private helpers, 3 view structs, GatewayAuthenticationState enum, 31 tests
commands/mod.rs Add pub mod gateway;
run.rs Remove gateway code (-2,415 lines), add pub use re-exports for the 10 public functions
test_utils.rs NewEnvVarGuard and with_tmp_xdg shared test helpers
lib.rs Add #[cfg(test)] pub(crate) mod test_utils;

What moved

  • Public functions: gateway_status, gateway_info, gateway_info_not_configured, gateway_use, gateway_select, gateway_add, gateway_login, gateway_logout, gateway_list, gateway_remove
  • Private helpers: gateway_service_status_name, print_gateway_info, gateway_info_to_json, gateway_env_override_warning, formatting helpers, TLS/mTLS helpers, auth state helpers, health check, etc.
  • Tests: All 31 gateway-related tests including select, JSON serialization, auth label, env override, mTLS, plaintext locality, add/rollback, health check, and status JSON tests

What stays in run.rs

  • ProgressOutput enum (sandbox domain)
  • Provider, service, settings, inference, and sandbox functions (PRs 3–6)
  • Non-gateway tests

Testing

  • cargo build -p openshell-cli — passes
  • cargo test -p openshell-cli — all 379 tests pass
  • cargo clippy -p openshell-cli — clean
  • No changes to main.rs — re-exports preserve all existing call paths

Checklist

  • Code follows project conventions
  • Conventional commit format used
  • No external API changes (re-exports preserve paths)
  • Tests pass
  • No new warnings

Move gateway management functions (gateway_status, gateway_info,
gateway_add, gateway_select, gateway_login, gateway_logout, gateway_list,
gateway_remove, gateway_use, gateway_info_not_configured) and their
private helpers from run.rs into commands/gateway.rs. Add pub use
re-exports in run.rs so main.rs call sites remain unchanged.

Extract shared test utilities (EnvVarGuard, with_tmp_xdg) into a
crate-level test_utils module to avoid duplication between gateway
tests and the remaining run.rs tests.

Part of NVIDIA#2304 (PR 2/6).

Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@drew drew left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

gator-agent

PR Review Status

Validation: This PR is project-valid because it implements PR 2 of the maintainer-backed CLI refactor tracked in #2304, and the scope is concentrated to extracting gateway command code and tests from run.rs while preserving public call paths through re-exports.
Head SHA: ceb510b9572b0faefe305b718f53c7baa9551d44

Review findings:

  • No blocking findings remain. The independent review found this to be a mechanical extraction with the gateway tests moved alongside the implementation and the existing run.rs call paths preserved.

Docs: not needed because this is intended to be behavior-preserving and does not change CLI commands, flags, output contracts, or docs navigation.

E2E: Applying test:e2e because the moved code covers gateway management flows. I am also posting /ok to test for this head SHA so the copy-pr mirror can run required checks.

Next state: gator:watch-pipeline

@drew drew added gator:watch-pipeline Gator is monitoring PR CI/CD status test:e2e Requires end-to-end coverage labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/2506 does not exist yet. A maintainer needs to comment /ok to test ceb510b9572b0faefe305b718f53c7baa9551d44 to mirror this PR. Once the mirror exists, re-apply the label or re-run Branch E2E Checks from the Actions tab.

@drew

drew commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

/ok to test ceb510b

@drew drew added gator:approval-needed Gator completed review; maintainer approval needed and removed gator:watch-pipeline Gator is monitoring PR CI/CD status labels Jul 27, 2026
@drew
drew added this pull request to the merge queue Jul 28, 2026
@drew drew added gator:merge-ready and removed gator:approval-needed Gator completed review; maintainer approval needed labels Jul 28, 2026
Merged via the queue into NVIDIA:main with commit 24d491a Jul 28, 2026
59 of 62 checks passed
@drew

drew commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

gator-agent

Monitoring Complete

Monitoring is complete because this PR has merged.

Final status: PR #2506 had reached gator:merge-ready with maintainer approval present, required gator review completed for head SHA ceb510b9572b0faefe305b718f53c7baa9551d44, and the PR merged on 2026-07-28T01:01:49Z.

I removed the active gator:* label because there is nothing left for gator to monitor on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants