extract_all_tags() scans SQL for specially formatted comment tags (e.g., -- @tag: value)
and returns them as a named list. This is exported with the intent to be useful for users
extending qryflow. It's typically used against a single SQL chunk, such as one parsed from a
.sql file.
Arguments
- text
A character vector of SQL lines or a file path to a SQL script.
A named list of tags, typically from
extract_all_tags(). Used insubset_tags().- keep
A character vector of tag names to keep or exclude in
subset_tags().- negate
Logical; if
TRUE,subset_tags()returns all tags except those listed inkeep.
Value
extract_all_tags(): A named list of all tags found in the SQL chunk.subset_tags(): A filtered named list of tags orNULLif none remain.
Examples
filepath <- example_sql_path('mtcars.sql')
parsed <- qryflow_parse(filepath)
chunk <- parsed[[1]]
tags <- extract_all_tags(chunk$sql)
subset_tags(tags, keep = c("query"))
#> list()