FR: Simple glob syntax for Angle Brackets
More syntax sugar for includes, like:
<cli/{*}> # includes all sub-aspects for this aspect (alias for attrValues trick?)
<cli/{btop,bat}> # expands to include `cli._.btop` and `cli._.bat`
Originally posted by @theutz in https://github.com/vic/den/discussions/329#discussioncomment-16474776
My recommendation is just create a function getAttrByGlob that takes the same arguments as lib.getAttrByPath, and replace usage of the later in our angle brackets implementation. Tests can use getAttrByGlob directly to test globs work correctly. And then have other tests that ensure the result is an aspect including aspects that match the glob.
@theutz what if I name my provider "btop,bat" because I'm a monster
... what if I name it "*"? :)
I suppose we'd have to add to the docs that, if you're going to use __findFile, you can't have { } , * in the names? I can try and provide a good error message.
Do you think we should fallback to a literal reading of the filename if the glob fails but literal doesn't?
Do you think we should fallback to a literal reading of the filename if the glob fails but literal doesn't?
No. No file-system access from Den, no imports. Our __findFile is named like that just for the angle bracket Nix syntax to work, but it is nothing related to files.
Sorry, I mistyped there. Should've written:
Do you think we should fallback to a literal reading of the aspect name?
Oh you mean if foo,bar does not match, try a literal foo,bar named aspect ? yeah, sounds good.
See also: https://github.com/vic/den/pull/401#issuecomment-4208832044