2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-26 13:30:30 +00:00
bazel-lib/lib/jq.bzl
2021-12-14 17:59:52 -08:00

33 lines
896 B
Python

"""Public API for jq"""
load("//lib/private:jq.bzl", _jq_lib = "jq_lib")
_jq_rule = rule(
attrs = _jq_lib.attrs,
implementation = _jq_lib.implementation,
toolchains = ["@aspect_bazel_lib//lib:jq_toolchain_type"],
)
def jq(name, srcs, filter, args = [], out = None):
"""Invoke jq with a filter on a set of json input files.
For jq documentation, see https://stedolan.github.io/jq/.
Args:
name: Name of the rule
srcs: List of input json files
filter: mandatory jq filter specification (https://stedolan.github.io/jq/manual/#Basicfilters)
args: additional args to pass to jq
out: Name of the output json file; defaults to the rule name plus ".json"
"""
if not out:
out = name + ".json"
_jq_rule(
name = name,
srcs = srcs,
filter = filter,
args = args,
out = out,
)