globlin

Types

Each path pattern holds a compiled regex and options.

pub opaque type Pattern
  • AbsolutePatternFromDirError
    • The pattern must NOT start with a slash if compiled with a directory prefix.
  • InvalidGlobStarError
    • The globstar (“**”) must always appear between the end of a string and/or a slash.
  • MissingClosingBracketError
    • A char set or range was opened but never closed.
  • RegexCompileError
    • Error propogated from the gleam/regex library.
    • This should NEVER happen so let me know if you ever see this.
pub type PatternError {
  AbsolutePatternFromDirError
  InvalidGlobStarError
  MissingClosingBracketError
  RegexCompileError(context: regex.CompileError)
}

Constructors

  • AbsolutePatternFromDirError
  • InvalidGlobStarError
  • MissingClosingBracketError
  • RegexCompileError(context: regex.CompileError)

Options that can be provided to the new_pattern_with method.

  • ignore_case: All matching is case insensitive (Default: False)
  • match_dotfiles: Match dotfiles when using wildcards (Default: False)
pub type PatternOptions {
  PatternOptions(ignore_case: Bool, match_dotfiles: Bool)
}

Constructors

  • PatternOptions(ignore_case: Bool, match_dotfiles: Bool)

Functions

pub fn match_pattern(
  pattern pattern: Pattern,
  path path: String,
) -> Bool

Compare a path pattern against a path to see if they match.

pub fn new_pattern(
  pattern: String,
) -> Result(Pattern, PatternError)

Compile a Pattern from a pattern.

pub fn new_pattern_with(
  pattern: String,
  from directory: String,
  with options: PatternOptions,
) -> Result(Pattern, PatternError)

Compile a Pattern from a directory, pattern and options. The directory is escaped and prefixed before the pattern.

Search Document