ci: coccinelle: Add support to write to a file

Add parameter to write the script output to a file.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
diff --git a/scripts/ci/guideline_check.py b/scripts/ci/guideline_check.py
index 44752e3..546ed93 100755
--- a/scripts/ci/guideline_check.py
+++ b/scripts/ci/guideline_check.py
@@ -41,6 +41,8 @@
         description="Check if change requires full twister")
     parser.add_argument('-c', '--commits', default=None,
                         help="Commit range in the form: a..b")
+    parser.add_argument("-o", "--output", required=False,
+                        help="Print violation into a file")
     return parser.parse_args()
 
 
@@ -75,10 +77,16 @@
                     violation = "{}:{}".format(f.path, line.target_line_no)
                     if violation in violations:
                         numViolations += 1
-                        print(
-                            "{}:{}".format(
-                                violation, "\t\n".join(
-                                    violations[violation])))
+                        if args.output:
+                            with open(args.output, "a+") as fp:
+                                fp.write("{}:{}\n".format(
+                                    violation, "\t\n".join(
+                                        violations[violation])))
+                        else:
+                            print(
+                                "{}:{}".format(
+                                    violation, "\t\n".join(
+                                        violations[violation])))
 
     return numViolations