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
Add arch
cask DSL
#13657
Add arch
cask DSL
#13657
Conversation
Review period will end on 2022-08-08 at 20:09:31 UTC. |
ed1c23f
to
dd72f1a
Compare
Love this.
I think this is unnecessarily confusing and unintuitive. Can you explain why this is needed and why If we really, really want to have some sort of "multi-variable arch" I'd suggest something like this: arch arm: { default: "arm", livecheck: "darwin-arm64" }
arch.to_s # returns "arm" on arm and "" on intel
arch.default.to_s # returns "arm" on arm and "" on intel
arch.livecheck.to_s # returns "darwin-arm64" on arm and "" on intel |
It looks like there are currently 16 cases of this. So not super common. Either way, it's a small number of casks that are impacted, so I think it's a decision between adding the |
less intuitive system IMO 👍🏻 |
Review period ended. |
I realized I'm not 100% sure what you were talking about here. It sounds like we're on the same page about not adding Were you talking about defaulting to an array when one parameter is blank and the other is an array? If so, I don't feel strongly about that and am happy to simply default to |
Sorry, I mean specifically I don't think we should ever be passing in an array here. This should be two separate variables, one being |
Gotcha. That is what I thought you meant. I think I'm okay with using a hash instead of relying on Also, in case it wasn't clear: the |
I defer to you there. My opinion is probably "less intuitive system" for those 👍🏻 |
👍 Okay. It's also easier to implement the array method, so I'll stick with that for now. I think this PR is ready now |
Library/Homebrew/cask/dsl.rb
Outdated
# If arm and intel are arrays and one isn't specified, default to an array that is the same size as the other | ||
empty_value = Array.new(arm&.count || intel&.count) if arm.is_a?(Array) || intel.is_a?(Array) |
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.
Sorry, my apologies for poor communication: I'm proposing that this only accepts values and not arrays and that they array form we move into two separate declarations e.g.
arch arm: "arm", intel: "intel"
livecheck_arch = something_else arm: "larm", intel: "lintel"
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.
Hmm, this is what I thought you meant by
My opinion is probably "less intuitive system" for those 👍🏻
What is the "less intuitive system" in your mind?
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.
The example I've had here is what I considered the "less intuitive" system although it's probably "more intuitive" 😅
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.
Hahaha okay, gotcha! I'm okay with either one since it's so few cases. Let me revert this back to include the original DSL proposal and see if that's what you're looking for.
As discussed in Homebrew/homebrew-cask#129182, this PR adds two new DSL items to casks. The first is an
arch
method which takes two items and, when called without arguments, will return whichever item corresponds to the current arch. Here's an example:On arm the url will be
https://example.com/foo/1.0.0/darwin-arm64/foo.dmg
and on Intel it will behttps://example.com/foo/1.0.0/darwin/foo.dmg
.There are several casks that currently have multiple variables that change based on
Hardware::CPU.type
, but instead of adding anon_arch_conditional
method, I suggest we simply pass arrays toarch
like this:Additionally, you can currently leave off either the
arm
orintel
parameter to default tonil
(which converts to""
when interpolated). If you pass an array toarch
and leave off the other arch parameter, it will default to an array of the same size filled withnil
. For example: