From 7584cebe2316c0efe0a8e5f579239507aca64ece Mon Sep 17 00:00:00 2001 From: Xenia Lang Date: Fri, 26 Apr 2024 14:42:21 +0200 Subject: [PATCH] #37: Add current OS Signed-off-by: Xenia Lang --- please.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/please.sh b/please.sh index b7fad84..fdce70c 100755 --- a/please.sh +++ b/please.sh @@ -184,8 +184,24 @@ get_key_from_keychain() { OPENAI_API_KEY="${key}" } +get_os() { + unameOut=$(uname -s) + case "$unameOut" in + Darwin) + os="MacOS" + ;; + Linux) + ;& + *) + # Any windows solutions are assumed to be Linux compatibla + os="Linux" + ;; + esac +} + get_command() { - role="You translate the given input into a Linux command. You may not use natural language, but only a Linux shell command as an answer. + os=get_os + role="You translate the given input into a bash command for $os. You may not use natural language, but only a bash command as an answer. Do not use markdown. Do not quote the whole output. If you do not know the answer, answer with \\\"${fail_msg}\\\"." payload=$(printf %s "$commandDescription" | jq --slurp --raw-input --compact-output '{