Is there any OCaml library out there to parse files defining globs (e.g., *.c) like the
one found in .gitignore for example, and providing functions to filter files based on
those globs.
I know I can make my own using regexp libraries out there (pcre, ocaml-re, etc.) but there are lots of special cases and conventions in those .gitignore that I don’t want to re-implement, for example you can skip files with foo.c or /foo.c in which case the second one applies only at the toplevel.
path_glob is another library doing something similar with a slightly different globbing syntax. It comes from the ocamlbuild codebase (_tags file use globbing), someone asked me to extract it as a small standalone library to reuse it.
I basically need an OCaml version of this Python library Introduction - Wildcard Match Documentation which supports advanced Bash globbing like **, !(…), path centric globs, etc.
Basically whatever you can use in a .gitignore file. I can’t use another syntax because I rely on the fact that most people are vaguely familiar with the format used in .gitignore files.
One solution, as proposed above, would be to add a new frontend syntax for ocaml-re. It is not particularly difficult, especially since you can start from Re_glob.