-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
33 lines (24 loc) · 829 Bytes
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
sentence="$*"
# Function to prompt for user confirmation
confirm_execution() {
read -p "$(tput setaf 4)> Execute? $(tput setaf 2)[yes] $(tput setaf 1)[no] $(tput setaf 3)[edit]$(tput sgr0): " execute_option
case $execute_option in
yes)
eval "$1"
;;
edit)
read -e -p "$(tput setaf 4)> Modify the command: $(tput sgr0)" -i "$answer" modified_command
confirm_execution "$modified_command"
;;
*)
echo "Execution canceled."
;;
esac
}
json_payload="{\"question\": \"$sentence\"}"
answer=$(curl -s --location 'https://hy655ghxvselxbedcujjfdxhgm0iwhua.lambda-url.eu-north-1.on.aws/' \
--header 'Content-Type: application/json' \
--data "$json_payload")
echo "$answer"
confirm_execution "$answer"