[Refactor] Split code into separate files for better organization/maintainability#12
Merged
AliSoftware merged 2 commits intotrunkfrom Dec 11, 2025
Merged
[Refactor] Split code into separate files for better organization/maintainability#12AliSoftware merged 2 commits intotrunkfrom
AliSoftware merged 2 commits intotrunkfrom
Conversation
ae62c52 to
0d569f0
Compare
d370016 to
cec9bcf
Compare
# Conflicts: # src/main.rs # Conflicts: # src/main.rs
0d569f0 to
e309a6a
Compare
iangmaia
reviewed
Dec 11, 2025
Numbered list index fix Co-authored-by: Ian G. Maia <iangmaia@users.noreply.github.com>
iangmaia
approved these changes
Dec 11, 2025
Contributor
iangmaia
left a comment
There was a problem hiding this comment.
Nice work 👏 I tested it by recompiling and running the main commands just in case, everything still looking good 👍
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.
Note
This PR builds on top of #11
What
Just moving the code around to spread it in dedicated
commands/*.rsfiles for better organization.The diff is mostly just code being cut-and-pasted from one place to another (mostly from
main.rsto the relevantcommands/*.rs) without change (except adjusting theuseimports and the like).Detail of moved code
fn cmd_init+init_instructionsfrommain.rstocommands/init.rsfn cmd_unlockfrommain.rstocommands/unlock.rsfn cmd_lockfrommain.rstocommands/lock.rsfn cmd_statusfrommain.rstocommands/status.rs, alongside the related types that were instatus.rsbefore (struct RepositoryStatus,struct FileStatus,struct FileStatusList)fn cmd_key_show+cmd_key_rotate+confirm+rotate_confirmation_prompt+rotate_instructionsfrommain.rstocommands/key.rsfilter.rstocommands/filter.rs(content unchanged)main.rsonly:enumdeclarations for the commands and subcommands (enum Commands,enum KeyCommands,enum FilterCommandsfn main() { match cli.command … }that tells whichcmd_*method to call for each command being matched during CLI parsingfn cmd_keyandfn cmd_filtermethods—that were doing the dispatch for the corresponding subcommands—to instead inline them as a nestedmatchinside thefn main()dispatch logicWhy
As the code is growing, this split makes the codebase more readable and maintainable IMHO, with clearer separation of what each
*.rsfile is about.For example, before this change, it wasn't clear that a file like
filter.rscontained code related to handling thefiltersubcommands, butkey.rswas NOT about handling thekeysubcommands—but instead a file containing model objects and business logic to manipulateKeyobjects. With this reorg, it's clearer that anything undercommands/*.rsis for handling commands and subcommands, while the rest of the model objects and business logic is outside this newcommandsmodule.Testing
Since this is just code being moved, the behavior shouldn't change. So as long as CI (which runs
cargo check,cargo clippy, andcargo build) passes, we should be OK.If you really want to validate the behavior of the tool hasn't changed, feel free to run
cargo build --releasefrom this PR's branch, add<path/to/this/repo>/target/releaseto your$PATH, then play around with PRs already implementinggit-conceallike woocommerce/woocommerce-android#14979 or Automattic/pocket-casts-android#4841