refactor(cli): split main() dispatch into per-group helper functions - #1999
Draft
github-actions[bot] wants to merge 1 commit into
Draft
refactor(cli): split main() dispatch into per-group helper functions#1999github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Extracts the Secrets, lifecycle (Enable/Disable/Remove/List/Status/Run/
Audit/Trace), export (ExportGateSchema/ExportFactCatalog/
ExportAdoProxyCatalog{,Schema}/ExportBashScripts), and inspect-group
(Inspect/Graph/Whatif/Lint/Catalog) match arms out of main() into
dispatch_secrets_command, dispatch_lifecycle_command,
dispatch_export_command, and dispatch_inspect_group_command.
No public API or behavior changes. main() shrinks from 355 to 186
lines (too_many_lines); full test suite and clippy --all-targets
--all-features pass clean.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
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.
What was complex
main()insrc/main.rshad grown to a singlematchonCommandsspanning ~355 lines (Clippytoo_many_linesthreshold is 100), handling every CLI subcommand's dispatch logic inline:Compile,Check,Mcp,McpAuthor,Execute,Init,Configure,Secrets(with a nested match),Enable,Disable,Remove,List,Status,Run,Audit,Trace, fiveExport*commands,Inspect,Graph(nested match),Whatif,Lint, andCatalog.What changed
Extracted four groups of match arms into standalone async/sync helper functions, each owning a cohesive slice of dispatch logic:
dispatch_secrets_command(action: SecretsCmd)— theSecrets::{Set,List,Delete}nested match.dispatch_lifecycle_command(command: Commands)—Enable,Disable,Remove,List,Status,Run,Audit,Trace(all share the same org/project/pat/path REST-client shape).dispatch_export_command(command: Commands)— the five hidden build-timeExport*commands (all synchronous generate-and-write/print operations).dispatch_inspect_group_command(command: Commands)—Inspect,Graph,Whatif,Lint,Catalog(read-only static-analysis commands over the compiled IR).main()now matches onCommandsand calls into these helpers for the extracted groups, keepingCompile,Check,Mcp,McpAuthor,Execute,Init, andConfigureinline since they have distinct pre/post logic (guards, background update-check spawn, etc.).No public API or observable behavior changes — every arm's body was moved verbatim into its new helper.
Before/after complexity
main()— 355 lines (clippy::too_many_lines, threshold 100)main()— 186 lines (clippy::too_many_lines); still above the lint threshold but roughly halved, and each extracted helper is a focused, independently readable/testable unit (dispatch_lifecycle_commandis the largest new helper).Verification
cargo build --bin ado-aw— cleancargo test— full suite passes (all packages/binaries)cargo clippy --all-targets --all-features— clean (one pre-existing, unrelated warning increate_work_item.rs)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.