From d532823aea28971d2ee0e147be5c3f494675fbe8 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 31 Mar 2023 10:09:59 +0800 Subject: Update gpt --- bin/gpt/gpt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bin/gpt') diff --git a/bin/gpt/gpt b/bin/gpt/gpt index e08e7c9..aa770bb 100755 --- a/bin/gpt/gpt +++ b/bin/gpt/gpt @@ -176,7 +176,7 @@ _get_content() { echo -e "$content" else content="$(printf "%s${data:+\\n\\n}%s" "$content" "$data")" - [ -n "$data" ] && echo "$data" + [ -n "$data" ] && echo -e "\n$data" fi } @@ -199,6 +199,11 @@ _process_completion() { fi } + +#===================================================== +# Main Function starts here +#===================================================== + # Check OPENAI API KEY in env # Exit with 6 (configuration issue) if it is not set [ -z "$OPENAI_API_KEY" ] && which token &>/dev/null && OPENAI_API_KEY=$(token openai) @@ -251,21 +256,23 @@ while [ "$#" -gt 0 ]; do _print_helper_message exit 0 ;; - *) - SKIP_INPUT=true - content="$1" - shift 1 - ;; --) SKIP_INPUT=true shift 1 content="$@" break ;; + *) + SKIP_INPUT=true + content="$1" + shift 1 + ;; esac done # Make sure necessary commands exist +# Since printing helper message doesn't need these +# So Check stacks after parsing arguments _check_stacks # Set variables in API calls -- cgit v1.2.3-70-g09d2