package dune-glob

  1. Overview
  2. Docs
Glob string matching language supported by dune

Install

Dune Dependency

Authors

Maintainers

Sources

dune-3.17.2.tbz
sha256=9deafeed0ecfe9e65e642cd8e6197f0864f73fcd7b94b5b199ae4d2e07a2ea64
sha512=1e85bb297a12c9571b8645541d85a719deffb619d5e4f48dbf4566ac14e9f385d8a05342698a6f9c81ba17325b1da4ad004a5772d66cd88ed135c43d43e88f9e

doc/index.html

dune-glob - file globbing

Introduction

A glob is a way of referring to a set of files that match a certain pattern, such as "files with the .ml extension" or "files with test in their name".

dune-glob exposes an abstraction so that we can refer to the first group as *.ml and the second one as *test*.

This library is used by Dune to implement this syntax in several places in dune files, but it can be used in other contexts as well.

Example

This is an executable that takes a glob as a command line argument, and lists the contents of the current directory that matches it:

let () =
  let glob_string = Sys.argv.(1) in
  let glob = Dune_glob.V1.of_string glob_string in
  let files = Sys.readdir "." in
  ArrayLabels.iter files ~f:(fun n ->
    if Dune_glob.V1.test glob n then
      print_endline n)

API documentation

The entry point for this library is Dune_glob.V1.

Note on stability

This library is fairly stable, but does not come with strong stability guarantees. In particular, while the module name suggests the API is versioned, it is not in the strict sense.

OCaml

Innovation. Community. Security.