refactor(cli): extract gateway commands into commands/gateway module - #2506
Conversation
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>
drew
left a comment
There was a problem hiding this comment.
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.rscall 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
|
Label |
|
/ok to test ceb510b |
Monitoring CompleteMonitoring is complete because this PR has merged. Final status: PR #2506 had reached I removed the active |
Summary
run.rs(~10,600 lines) intocommands/gateway.rspub usere-exports inrun.rssomain.rscall sites remain unchangedEnvVarGuard,with_tmp_xdg) to a newtest_utils.rsmodule for reuse across test modulesThis 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
commands/gateway.rsGatewayAuthenticationStateenum, 31 testscommands/mod.rspub mod gateway;run.rspub usere-exports for the 10 public functionstest_utils.rsEnvVarGuardandwith_tmp_xdgshared test helperslib.rs#[cfg(test)] pub(crate) mod test_utils;What moved
gateway_status,gateway_info,gateway_info_not_configured,gateway_use,gateway_select,gateway_add,gateway_login,gateway_logout,gateway_list,gateway_removegateway_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.What stays in
run.rsProgressOutputenum (sandbox domain)Testing
cargo build -p openshell-cli— passescargo test -p openshell-cli— all 379 tests passcargo clippy -p openshell-cli— cleanmain.rs— re-exports preserve all existing call pathsChecklist