Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#37: Add current OS #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion please.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest not to use bash as we do not know whether the user is actually using bash or another shell (such as zsh, fish, ...). I would suggest to either use the more generic shell (maybe even request the command to be POSIX compliant).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively one may retrieve information about the shell in use, e.g. from the SHELL env variable.

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 '{
Expand Down