add non-raw jq option
This commit is contained in:
parent
bb9d1a237c
commit
750c8d3e28
|
@ -98,10 +98,16 @@ class JqMapper(AbstractMapper):
|
||||||
return ["json", "bytes"]
|
return ["json", "bytes"]
|
||||||
|
|
||||||
def generate(self, input_name: str, output_formats: List[str]) -> ShellMapping:
|
def generate(self, input_name: str, output_formats: List[str]) -> ShellMapping:
|
||||||
# TODO: remove join hack with proper datatype analysis
|
if self._parsed.raw_output:
|
||||||
code = dedent(f"""\
|
# TODO: remove join hack with proper datatype analysis
|
||||||
filtered = "\\n".join(jq.all({self._parsed.filter!r}, text={input_name}))
|
code = dedent(f"""\
|
||||||
""")
|
filtered = "\\n".join(jq.all({self._parsed.filter!r}, text={input_name}))
|
||||||
|
""")
|
||||||
|
else:
|
||||||
|
code = dedent(f"""\
|
||||||
|
filtered = jq.text({self._parsed.filter!r}, text={input_name})
|
||||||
|
""")
|
||||||
|
|
||||||
return ShellMapping(code=code, output_name="filtered", output_format="str", input_format="", imports=["import jq"])
|
return ShellMapping(code=code, output_name="filtered", output_format="str", input_format="", imports=["import jq"])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue