This question already has an answer here:
I am looking for the equivalent of RHEL's
yum -y in ArchLinux's
pacman so that I can install packages with a shell script without asking the user questions.
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
The option you are looking for is
however, it is best to avoid using it and is highly recommended to always read and understand pacman's output.