From 439e935ec583eb7641152c32798898024859e939 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Fri, 5 May 2023 01:50:56 -0500 Subject: Add stdin as a input source for the inital prompt --- src/gpt_chat_cli/argparsing.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/gpt_chat_cli/argparsing.py') diff --git a/src/gpt_chat_cli/argparsing.py b/src/gpt_chat_cli/argparsing.py index 7d1d305..81a9b47 100644 --- a/src/gpt_chat_cli/argparsing.py +++ b/src/gpt_chat_cli/argparsing.py @@ -64,9 +64,10 @@ class DebugArguments: class Arguments: completion_args: CompletionArguments display_args: DisplayArguments + version: bool debug_args: Optional[DebugArguments] = None -def split_arguments(args: argparse.Namespace, debug=False) -> Arguments: +def split_arguments(args: argparse.Namespace) -> Arguments: completion_args = CompletionArguments( model=args.model, n_completions=args.n_completions, @@ -83,15 +84,17 @@ def split_arguments(args: argparse.Namespace, debug=False) -> Arguments: color=(args.color == AutoDetectedOption.ON), ) - if debug: - debug_args = DebugArguments( - save_response_to_file=args.save_response_to_file, - load_response_from_file=args.load_response_from_file, - ) - else: - debug_args = None + debug_args = DebugArguments( + save_response_to_file=args.save_response_to_file, + load_response_from_file=args.load_response_from_file, + ) - return Arguments( completion_args, display_args, debug_args ) + return Arguments( + completion_args=completion_args, + display_args=display_args, + debug_args=debug_args, + version=args.version + ) def parse_args() -> Arguments: @@ -198,9 +201,17 @@ def parse_args() -> Arguments: help="Set color to 'on', 'off', or 'auto'.", ) + parser.add_argument( + "--version", + # type=bool, + action="store_true", + help="Print version and exit" + ) + parser.add_argument( "message", type=str, + nargs='?', help=( "The contents of the message. When used in chat mode, this is the initial " "message if provided." @@ -255,4 +266,4 @@ def parse_args() -> Arguments: validate_args(args) - return split_arguments(args, debug=debug) + return split_arguments(args) -- cgit v1.2.3