# -*- coding: utf-8 -*-
#!/usr/bin/python
##-------------------------------------------------------------------
## @copyright 2017 DennyZhang.com
## Licensed under MIT
##   https://raw.githubusercontent.com/DennyZhang/devops_public/master/LICENSE
##
## File : enforce_shellcheck.py
## Author : Denny <denny@dennyzhang.com>
## Description :
## --
## Created : <2017-04-02>
## Updated: Time-stamp: <2017-04-02 21:05:28>
##-------------------------------------------------------------------
import argparse
import sys

def find_sh_files(working_dir, shellcheck_ignore_file):
    l = []

def run_shell_check(sh_file_list, exclude_code_list):
    l = []

if __name__ == '__main__':
    # get parameters from users
    parser = argparse.ArgumentParser()
    parser.add_argument('--code_dir', required=True, \
                        help="Source code directory to be scanned", type=str)
    parser.add_argument('--shellcheck_ignore_file', required=False, \
                        help="file pattern listed in the file will be skipped for scan", type=str)
    parser.add_argument('--exclude_code_list', required=False, \
                        default="SC1090,SC1091,SC2154,SC2001,SC2002,SC2181", \
                        help="shellcheck code to be skipped", type=str)
    l = parser.parse_args()
    
    shellcheck_ignore_file = l.shellcheck_ignore_file
    exclude_code_list = l.exclude_code_list
## File : enforce_shellcheck.py ends

@@ -409,12 +409,12 @@
 21:0
-5:28
+8:37
 %3E%0A##
@@ -569,22 +569,65 @@
 e):%0A    
-l = %5B%5D
+# TODO: to be implemented%0A    l = %5B%5D%0A    return l
 %0A%0Adef ru
@@ -678,22 +678,68 @@
 t):%0A    
-l = %5B%5D
+# TODO: to be implemented%0A    l = %5B%5D%0A    return True
 %0A%0Aif __n
@@ -1381,16 +1381,42 @@
 ()%0A    %0A
+    code_dir = l.code_dir%0A
     shel
@@ -1504,16 +1504,264 @@
 ode_list
+%0A%0A    sh_file_list = find_sh_files(code_dir, exclude_code_list)%0A    has_pass = run_shell_check(sh_file_list, exclude_code_list)%0A    if has_pass is True:%0A        sys.exit(0)%0A    else:%0A        print %22ERROR: shellcheck has failed.%22%0A        sys.exit(1)
 %0A## File

add code snippet