From ed567afbeac07b7426e230991e74d1f50a32bb97 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Fri, 8 Sep 2023 15:54:29 +0200 Subject: [PATCH] Make it possible to print just question or answer on printing files. --- chatmastermind/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chatmastermind/main.py b/chatmastermind/main.py index 32e4ccd..c30ea4e 100755 --- a/chatmastermind/main.py +++ b/chatmastermind/main.py @@ -125,6 +125,10 @@ def print_cmd(args: argparse.Namespace, config: Config) -> None: sys.exit(1) if args.only_source_code: display_source_code(data['answer']) + elif args.answer: + print(data['answer'].strip()) + elif args.question: + print(data['question'].strip()) else: print(dump_data(data).strip()) @@ -213,8 +217,10 @@ def create_parser() -> argparse.ArgumentParser: aliases=['p']) print_cmd_parser.set_defaults(func=print_cmd) print_cmd_parser.add_argument('-f', '--file', help='File to print', required=True) - print_cmd_parser.add_argument('-S', '--only-source-code', help='Print only source code', - action='store_true') + print_cmd_modes = print_cmd_parser.add_mutually_exclusive_group() + print_cmd_modes.add_argument('-q', '--question', help='Print only question', action='store_true') + print_cmd_modes.add_argument('-a', '--answer', help='Print only answer', action='store_true') + print_cmd_modes.add_argument('-S', '--only-source-code', help='Print only source code', action='store_true') argcomplete.autocomplete(parser) return parser