github.com/zmap/zlint@v1.1.0/newLint.sh (about)

     1  # Script to create new lint from template
     2  
     3  USAGE="Usage: $0 <ARG1> <ARG2>
     4  
     5  ARG1: File_name/TestName (no 'lint_' prefix)
     6  ARG2: Struct_name"
     7  
     8  if [ $# -eq 0 ]; then
     9      echo "No arguments provided..."
    10      echo "$USAGE"
    11      exit 1
    12  fi
    13  
    14  if [ $# -eq 1 ]; then
    15      echo "Not enough arguments provided..."
    16      echo "$USAGE"
    17      exit 1
    18  fi
    19  
    20  if [ -e lint_$1.go ]
    21  then
    22     echo "File already exists. Can't make new file."
    23     exit 1
    24  fi
    25  
    26  FILENAME=$1
    27  TESTNAME=$2
    28  
    29  cp template lints/lint_$FILENAME.go
    30  
    31  cat "lints/lint_$FILENAME.go" | sed "s/SUBST/$2/g" | sed "s/SUBTEST/$1/g" > temp.go
    32  mv -f temp.go "lints/lint_$FILENAME.go"
    33  
    34  echo "Created file lint_$FILENAME.go with test name $TESTNAME"