You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, great library you have here! We are building a file globbing library (https://github.com/goreleaser/fileglob) on top of glob which required us to write some helper functions that operate on glob/syntax/ast. Maybe some of these functions are useful to your users and could be exposed directly in the glob library.
ContainsMatchers: Returns true if the pattern contains matchers and false otherwise. This is useful to determine whether the pattern directly references a file or multiple files via matchers.
UnquoteMeta: For patterns without matchers, return the static text represented by the pattern. This is useful to determine which file is directly referenced by a pattern that may contain escaped matchers.
Currently, using these functions in our package results in the pattern being parsed multiple times: Once for every function and then finally for the actual compilation.
Hi, great library you have here! We are building a file globbing library (https://github.com/goreleaser/fileglob) on top of
glob
which required us to write some helper functions that operate onglob/syntax/ast
. Maybe some of these functions are useful to your users and could be exposed directly in theglob
library.Consider the following example (source code can be found here: https://github.com/goreleaser/fileglob/blob/main/prefix.go):
ContainsMatchers
: Returnstrue
if the pattern contains matchers andfalse
otherwise. This is useful to determine whether the pattern directly references a file or multiple files via matchers.UnquoteMeta
: For patterns without matchers, return the static text represented by the pattern. This is useful to determine which file is directly referenced by a pattern that may contain escaped matchers.Currently, using these functions in our package results in the pattern being parsed multiple times: Once for every function and then finally for the actual compilation.
Also, it would be useful to allow for AST manipulation. This could be used to inject globbing options, perform queries on the AST (like the functions above) or to extend the functionality of this library. https://github.com/antonmedv/expr uses a great pattern for this, the
Patcher
: https://github.com/antonmedv/expr/blob/master/docs/Visitor-and-Patch.md. Inglob
this could be done by passing a variadic list of function operating on the AST to theCompile
function:What do you think? If you think these ideas are not a good fit for
glob
you can close this issue.The text was updated successfully, but these errors were encountered: