Skip to contents

Search for files under a directory using shell-style glob matching.

Usage

tool_glob_files(pattern = "*", path = ".", recursive = TRUE)

Format

A tool definition created with ellmer::tool().

Arguments

pattern

Glob pattern to match (tool argument)

path

Base directory to search (tool argument)

recursive

If TRUE, search subdirectories recursively (tool argument)

Value

When called directly, a character summary of paths matching the glob pattern.

Examples

directory <- tempfile()
dir.create(directory)
writeLines("example", file.path(directory, "example.txt"))
tool_glob_files("*.txt", directory)
#> [1] "Base path: /tmp/RtmpJxzN8D/file1b545c6da403\nMatches: 1\n\nexample.txt"
unlink(directory, recursive = TRUE)