-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Cleanup ARGV usage #5730
Comments
This seems like something I'd be happy to help out with, though it seems like an incremental approach to this is best (rather than getting rid of it all in one PR) Would this be a reasonable way to do that?
And then after repeating step 3 on all the various One other clarification: Is the goal to add more info into the For example, we could pre-compute the named arguments and add it as a field to |
@BenMusch Sounds great!
I think we can avoid precomputing but we could cache it intelligently. Part of the motivation for this is that I don't think we will need to do it for every ARGV method; some of them will be able to be removed or replaced with better APIs. Any that aren't used in Homebrew/brew or Homebrew/homebrew-core can be considered internal APIs and removed. Even among those it may be they can be refactored so they aren't needed. The easy ones to start with should be those like |
I've updated the original issue a bit now #6021 is merged which should simplify things a bit. |
Could I start to work on this? |
@jeduardo824 Yes, please! |
Hi! I'd like to work on this issue, but I'm having trouble running the tests. What is the command to run them? I tried |
Tests can be run using |
Hi @TedTran2019! I am working on this in my free time, but you can work on this too, #6433 is part of the on-going effort. You can take a look at the other PRs referenced here to get an idea. |
In a tap of mine (homebrew-upup) I use the |
@goibon You can just replace |
@goibon Use |
@goibon Sorry for the inconvenience but that was essentially a private API 😭. I hope in the near future to be able to provide an example in e.g. Homebrew/bundle of using |
@issyl0 already made first steps, to provide an example how to use it in a tap: https://github.com/Homebrew/homebrew-linux-dev/pull/137. |
Note to @goibon and @GauthamGoli: all Homebrew organisation tap commands are now using |
@MikeMcQuaid @GauthamGoli Thanks for the pointers, I switched to using require "cli/parser"
def announce_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`upup` [`--cleanup`][`--quiet`]
EOS
switch "--cleanup",
description: "Calls brew cleanup after the last step"
switch "--quiet",
description: "Runs quietly with no output unless something goes wrong"
end
end
announce_args.parse |
@goibon Check the other PRs. TL;DR you need to:
|
Now we have a proper argument parser (thanks @GauthamGoli!) we should replace all uses of ARGV in the Homebrew/brew codebase with calls to
Homebrew.args
instead.extend/ARGV.rb should be moved into https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cli/args.rb where needed or removed where not. This may warrant changes to formulae and
odeprecated
.Note
formula_installer.rb
andbuild.rb
should be handled last as they read from and modify ARGV:brew/Library/Homebrew/formula_installer.rb
Lines 678 to 751 in b4f73e6
No need to say "I'm planning on working on this" or similar in this issue but feel free to open a PR that doesn't work (yet!) and ask for help.
The text was updated successfully, but these errors were encountered: