-
Notifications
You must be signed in to change notification settings - Fork 142
vargo: refactor to use clap and clean up code
#2060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9b04112 to
70bf673
Compare
3f89d34 to
aa65fd3
Compare
|
FYI, I have ready some more wholesale refactorings ready. Mainly moving error handling to |
tjhance
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me, though please also get a review from @parno who knows more about build needs than I do.
|
One other thing that I was wondering about was VARGO_NEST. It seems to serve the purpose of counting how many times vargo is calling itself. But this refactoring eliminates that pattern. Might be worth removing it. Similarly the |
I now understand that |
98bdb6a to
c02f3ea
Compare
This simplifies their call site Also moved to yansi 1.0
they're only used when building (except one that is only used when formatting)
Motivation
Vargo is quite inscrutable from a user perspective. Besides the most basic subcommands, figuring out the options requires looking over the code. However, vargo's code was... complicated.
This PR refactors vargo into a hopefully cleaner structure, which would allow new contributors to have a better experience when developing and would allow us to add support for more
cargocommands without much hassle (e.g., I think runningcargo-clippyon our codebase might be worthwhile).Apologies for the big diff. I sincerely could not find a piecemeal way of breaking this up. See Testing for more details on how I validated the changes were correct.
The changes
This started as a migration to
clap, which will help us by having a nice cli help cmd.new CLI interface
`vargo build` CLI example
Because of vargos previously intertwined structure (argument parsing and execution were intermingled, and executing a subcommand was done in stages, mixed with more argument parsing, in a function with 1000+ lines) the diff is less than clean (i.e., it shows a full removal and full addition, even though many core lines of code were just transplanted into their own functions)
But, overall, the changes are as follows:
climodule that handles parsing withclapcontextmodule that builds the context forvargo(e.g., where is the target dir)commandsmodule. Each submodule corresponds to a subcommand (e.g.,vargo build), and implements the core logic for that commandSmtBinary...functions were moved to asmt_solvermoduleTesting
Because the changes are so large, I suspect reviewing per line of code will be less than scalable.
To that end, here I scripts I developed to test the changes. They essentially run
vargoin verbose mode and allow for comparing the logs between the old and new version. I recommend running them on two fresh clones of the repo.Test Script (test_vargo.sh)
Comparing logs (log_check.sh)
To run and verify the tests, do the following.
Warning: running test_vargo will change the repo (it will write log files and run
vargo update). Exercise caution.(You can also extract the cmp_logs function from the script to analyze a particular log).
The main things I've found:
--package <p>instead of-p <p>These were the main differences I could grok. Functionally, they seem equivalent.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.