From a73ee47bcf5c6d50ae8e5c8ccafe0d41f7bb9c16 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 5 Jan 2024 17:44:30 -0800 Subject: [PATCH] move slurp error message so it will work for all parser types --- jc/cli.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jc/cli.py b/jc/cli.py index 72f68677..5e137a11 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -665,13 +665,6 @@ class JcCli(): def create_slurp_output(self) -> None: """Slurp output into an array. Only works for single-line strings.""" - if self.parser_module and not _parser_is_slurpable(self.parser_module): - utils.error_message([ - f'Slurp option not available with the {self.parser_name} parser.', - 'Use `jc -hhh` to find compatible parsers.' - ]) - self.exit_error() - if self.parser_module and isinstance(self.data_in, str): self.data_out = [] for line in self.data_in.splitlines(): @@ -830,6 +823,13 @@ class JcCli(): # parse and print to stdout if self.parser_module: + if self.slurp and not _parser_is_slurpable(self.parser_module): + utils.error_message([ + f'Slurp option not available with the {self.parser_name} parser.', + 'Use "jc -hhh" to find compatible parsers.' + ]) + self.exit_error() + try: if _parser_is_streaming(self.parser_module): self.streaming_parse_and_print()