In a Raku distribution how do I depend on either Foo::Bar
or Foo::Baz
without requiring both?
Asked
Active
Viewed 432 times
15
-
The tags I added do not serve the usual primary purpose of tags (to bring a question to attention of those who contribute to answering). I thought they might help bring your Q to the attention of those searching for answers, which I presume is a leading reason you write your Q+As, but would appreciate reading your reaction. For one thing, is [package] inappropriate? Either of the other two? If you would prefer I generally leave your questions unedited, including tags, I'd be fine with that too; please just let me know. TIA for any reply. And of course for zef, and your excellent Q+As. – raiph Dec 04 '20 at 13:23
-
1I'm using package as a generic, language agnostic term for what a distribution otherwise represents in raku. Theoretically `Foo:from
`, `Foo:from – ugexe Dec 04 '20 at 15:01` are valid dependencies (or even direct installation identities), and in that context 'package' feels like a more accurate description than 'distribution' or 'module'. Regardless; I don't spend much time thinking about my own tags lest I get stuck over analyzing minor details before my inspiration to answer is expired, and have no issues with anyone adding tags they think are appropriate.
1 Answers
16
You can use "any": [$dependency-spec1, $dependency-spec2]
. This could look like one of the following (depending on if you use a plain string dependency or a hash):
"depends" : {
"runtime" : {
"any" : [
"Foo::Bar",
"Foo::Baz"
]
}
}
"depends" : {
"runtime" : {
"any" : [
{
"name" : "Foo::Bar"
},
{
"name" : "Foo::Baz"
}
]
}
}
This isn't constrained to raku dependencies either. For instance to declare a dependency on either curl
or wget
one can do:
"depends" : {
"runtime" : {
"any" : [
"curl:from<bin>",
"wget:from<bin>"
]
}
}
which would cause zef install $whatever
to inform the user of the missing programs if none are found.

ugexe
- 5,297
- 1
- 28
- 49