diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index e26aef8..a017fce 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -68,7 +68,7 @@ class CLI: logger.error("Could not find the '%s' talker", self.config.Sources__source) raise SystemExit(2) - def output(self, *args: Any, file: TextIO | None = None, **kwargs: Any) -> None: + def output(self, *args: Any, file: TextIO | None = None, force_output: bool = False, **kwargs: Any) -> None: if file is None: file = self.output_file if not args: @@ -80,7 +80,7 @@ class CLI: logger.info(*log_args, **kwargs) if self.config.Runtime_Options__verbose > 0: return - if not self.config.Runtime_Options__quiet: + if not self.config.Runtime_Options__quiet or force_output: print(*args, **kwargs, file=file) def run(self) -> None: @@ -137,7 +137,7 @@ class CLI: return True def display_match_set_for_choice(self, label: str, match_set: Result) -> None: - self.output(f"{match_set.original_path} -- {label}:") + self.output(f"{match_set.original_path} -- {label}:", force_output=True) # sort match list by year match_set.online_results.sort(key=lambda k: k.year or 0) @@ -152,7 +152,8 @@ class CLI: m.month, m.year, m.issue_title, - ) + ), + force_output=True, ) if self.config.Runtime_Options__interactive: while True: diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 06fbc10..0b44007 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -113,7 +113,7 @@ def register_runtime(parser: settngs.Manager) -> None: "-i", "--interactive", action="store_true", - help="""Interactively query the user when there are\nmultiple matches for an online search.\n\n""", + help="""Interactively query the user when there are\nmultiple matches for an online search. Disabled json output\n\n""", file=False, ) parser.add_setting( @@ -160,7 +160,9 @@ def register_runtime(parser: settngs.Manager) -> None: parser.add_setting("--darkmode", action="store_true", help="Windows only. Force a dark pallet", file=False) parser.add_setting("-g", "--glob", action="store_true", help="Windows only. Enable globbing", file=False) parser.add_setting("--quiet", "-q", action="store_true", help="Don't say much (for print mode).", file=False) - parser.add_setting("--json", "-j", action="store_true", help="Output json on stdout", file=False) + parser.add_setting( + "--json", "-j", action="store_true", help="Output json on stdout. Ignored in interactive mode.", file=False + ) parser.add_setting( "-t", @@ -283,6 +285,9 @@ def validate_commandline_settings(config: settngs.Config[ct_ns], parser: settngs for item in globs: config[0].Runtime_Options__files.extend(glob.glob(item)) + if config[0].Runtime_Options__json and config[0].Runtime_Options__interactive: + config[0].Runtime_Options__json = False + if ( config[0].Commands__command != Action.save_config and config[0].Runtime_Options__no_gui