Add quiet option to script

This commit is contained in:
Josh Stewart 2022-09-07 15:57:41 +10:00
parent 1e3fe7c1b5
commit c84fdcd8f0
2 changed files with 7 additions and 2 deletions

View File

@ -30,8 +30,9 @@ jobs:
cd $GITHUB_WORKSPACE/misra/ cd $GITHUB_WORKSPACE/misra/
mkdir .results mkdir .results
chmod +x check_misra.sh chmod +x check_misra.sh
./check_misra.sh -c /usr/bin -o ./.results ./check_misra.sh -c /usr/bin -o ./.results -q
echo "Scan complete" echo "Scan complete"
echo $NumViolations
echo "VIOLATIONS=$NumViolations" >> $GITHUB_ENV echo "VIOLATIONS=$NumViolations" >> $GITHUB_ENV
- name: Save output to Gist - name: Save output to Gist

View File

@ -7,6 +7,7 @@ source_folder="$script_folder/../speeduino" # -s, --source
file_exts="ino" # -e, --exts file_exts="ino" # -e, --exts
out_folder="$script_folder/.results" # -o, --out out_folder="$script_folder/.results" # -o, --out
cppcheck_path="" # -c, --cppcheck cppcheck_path="" # -c, --cppcheck
quiet=0 # -q, --quiet
function parse_command_line() { function parse_command_line() {
while [ $# -gt 0 ] ; do while [ $# -gt 0 ] ; do
@ -15,6 +16,7 @@ function parse_command_line() {
-e | --exts) file_exts="$2" ;; -e | --exts) file_exts="$2" ;;
-o | --out) out_folder="$2" ;; -o | --out) out_folder="$2" ;;
-c | --cppcheck) cppcheck_path="$2" ;; -c | --cppcheck) cppcheck_path="$2" ;;
-q | --quiet) quiet=1 ;;
-*) -*)
echo "Unknown option: " $1 echo "Unknown option: " $1
exit 1 exit 1
@ -70,7 +72,9 @@ rm -f "$result_file"
run_cppcheck run_cppcheck
error_count="$(process_cpp_results)" error_count="$(process_cpp_results)"
cat "$result_file" if [ $quiet -eq 0 ]; then
cat "$result_file"
fi
echo $error_count MISRA violations echo $error_count MISRA violations
echo $error_count > ".results/error_count.txt" echo $error_count > ".results/error_count.txt"