refactor(cli): extract shared helpers into commands/common module#2359
refactor(cli): extract shared helpers into commands/common module#2359varshaprasad96 wants to merge 2 commits into
Conversation
Move shared formatting, parsing, display, and settings helpers from run.rs into a new commands/common.rs module. run.rs re-exports all public items so no callers change. This establishes the commands/ directory structure for the incremental run.rs split (NVIDIA#2304). Signed-off-by: Varsha Prasad Narsing <vnarsing@nvidia.com> Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
…ers extraction - Remove orphan doc comment left on sandbox_list after print_yaml_line extraction - Change `pub mod commands` to `pub(crate) mod commands` in lib.rs - Move 6 unnecessarily pub-exported items to private use imports in run.rs - Restore stripped rationale comment in parse_cli_setting_value Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
|
I'm curious about the decision for placing common.rs under commands/ rather than at the top level of src/. Since run.rs (which is at the parent level) imports from it, and the utilities seem fairly general-purpose, I'm wondering if src/common.rs might be cleaner? |
|
@2000krysztof - The fact that run.rs currently imports from commands/common is a transitional state, Placing it at src/common.rs would make it a peer of auth.rs, ssh.rs, tls.rs which are infrastructure modules, a different layer than command-specific helpers. |
|
Makes sense, thanks for the explanation. Looks good to me. |
Summary
Extract ~950 lines of shared helper functions, types, and parsing utilities from the monolithic
run.rs(10,138 lines) into a newcommands/common.rsmodule. This is PR 1 of 6 in the incremental CLI refactor tracked by #2304.Related Issue
Part of #2304
Changes
commands/mod.rsandcommands/common.rsmodule scaffoldingphase_name,format_epoch_ms,format_elapsed,format_timestamp,print_yaml_line,print_sandbox_policy,short_hash,non_empty_or,format_timestamp_ms,format_optional_epoch_ms,truncate_status_field,truncate_display,format_setting_valueparse_env_pairs,parse_key_value_pairs,parse_secret_material_env_pairs,parse_credential_*,parse_cli_setting_value,parse_duration_to_msPolicyGetView,ProvisioningStep,ProvisioningDisplaymain.rsand integration tests viapub useinrun.rspub(crate) mod commandsto keep the module crate-internalTesting
cargo fmtandcargo clippypass with zero warnings--helpoutput byte-identical across all subcommands (gateway, sandbox, provider, service, settings, policy, inference)Checklist