如何声明可以由许多不同名称的包之一实现的依赖项?

How do I declare a dependency that can be fulfilled by one of many differently named packages?

在 Raku 发行版中,我如何依赖 Foo::BarFoo::Baz 而不需要两者?

您可以使用 "any": [$dependency-spec1, $dependency-spec2]。这可能看起来像以下之一(取决于您使用的是纯字符串依赖项还是散列):

"depends" : {
    "runtime" : {
        "any" : [
            "Foo::Bar",
            "Foo::Baz"
        ]
    }
}
"depends" : {
    "runtime" : {
        "any" : [
            {
                "name" : "Foo::Bar"
            },
            {
                "name" : "Foo::Baz"
            }
        ]
    }
}

这也不限于 raku 依赖项。例如,要声明对 curlwget 的依赖,可以这样做:

"depends" : {
    "runtime" : {
        "any" : [
            "curl:from<bin>",
            "wget:from<bin>"
        ]
    }
}

如果找到 none,这将导致 zef install $whatever 通知用户丢失的程序。