diff options
Diffstat (limited to 'bin/gpt')
-rwxr-xr-x | bin/gpt/gpt | 19 |
1 files changed, 13 insertions, 6 deletions
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() { | |||
176 | echo -e "$content" | 176 | echo -e "$content" |
177 | else | 177 | else |
178 | content="$(printf "%s${data:+\\n\\n}%s" "$content" "$data")" | 178 | content="$(printf "%s${data:+\\n\\n}%s" "$content" "$data")" |
179 | [ -n "$data" ] && echo "$data" | 179 | [ -n "$data" ] && echo -e "\n$data" |
180 | fi | 180 | fi |
181 | } | 181 | } |
182 | 182 | ||
@@ -199,6 +199,11 @@ _process_completion() { | |||
199 | fi | 199 | fi |
200 | } | 200 | } |
201 | 201 | ||
202 | |||
203 | #===================================================== | ||
204 | # Main Function starts here | ||
205 | #===================================================== | ||
206 | |||
202 | # Check OPENAI API KEY in env | 207 | # Check OPENAI API KEY in env |
203 | # Exit with 6 (configuration issue) if it is not set | 208 | # Exit with 6 (configuration issue) if it is not set |
204 | [ -z "$OPENAI_API_KEY" ] && which token &>/dev/null && OPENAI_API_KEY=$(token openai) | 209 | [ -z "$OPENAI_API_KEY" ] && which token &>/dev/null && OPENAI_API_KEY=$(token openai) |
@@ -251,21 +256,23 @@ while [ "$#" -gt 0 ]; do | |||
251 | _print_helper_message | 256 | _print_helper_message |
252 | exit 0 | 257 | exit 0 |
253 | ;; | 258 | ;; |
254 | *) | ||
255 | SKIP_INPUT=true | ||
256 | content="$1" | ||
257 | shift 1 | ||
258 | ;; | ||
259 | --) | 259 | --) |
260 | SKIP_INPUT=true | 260 | SKIP_INPUT=true |
261 | shift 1 | 261 | shift 1 |
262 | content="$@" | 262 | content="$@" |
263 | break | 263 | break |
264 | ;; | 264 | ;; |
265 | *) | ||
266 | SKIP_INPUT=true | ||
267 | content="$1" | ||
268 | shift 1 | ||
269 | ;; | ||
265 | esac | 270 | esac |
266 | done | 271 | done |
267 | 272 | ||
268 | # Make sure necessary commands exist | 273 | # Make sure necessary commands exist |
274 | # Since printing helper message doesn't need these | ||
275 | # So Check stacks after parsing arguments | ||
269 | _check_stacks | 276 | _check_stacks |
270 | 277 | ||
271 | # Set variables in API calls | 278 | # Set variables in API calls |