Add arch cask DSL - #13657
Conversation
|
Review period will end on 2022-08-08 at 20:09:31 UTC. |
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 |
| # 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.
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.
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.
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.
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
archmethod 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.dmgand 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_conditionalmethod, I suggest we simply pass arrays toarchlike this:Additionally, you can currently leave off either the
armorintelparameter to default tonil(which converts to""when interpolated). If you pass an array toarchand leave off the other arch parameter, it will default to an array of the same size filled withnil. For example: