globlin
Types
An alias for simplifile.FileError needed for the glob methods below.
pub type FileError =
simplifile.FileError
- 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/regexlibrary. - This should NEVER happen so let me know if you ever see this.
- Error propogated from the
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 glob(pattern: Pattern) -> Result(List(String), FileError)
Glob files from the current working directory.
pub fn glob_from(
pattern pattern: Pattern,
directory directory: String,
) -> Result(List(String), FileError)
Glob files from a chosen directory.
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.